### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### Printers.pm - Printers module for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Control::Printers; use strict; use PSGConf::Data::Hash; use PSGConf::Data::List; use PSGConf::Data::String; use PSGConf::Data::Boolean; use PSGConf::Action::GenerateFile::printcap; use PSGConf::Action::lpadmin; use PSGConf::Action::svcs::import; use PSGConf::Control::Packages qw(_add_pkgs); use PSGConf::Control::syslog qw(_add_syslog); ############################################################################### ### policy methods ############################################################################### ### add inetd entry sub _policy_add_inetd_entry { my ($self, $psgconf) = @_; return if ( $psgconf->data_obj('print_enable')->equals('false') || ! $psgconf->data_obj('print_subsystem_type')->equals('SysV') || $psgconf->data_obj('platform')->match('solaris10') ); $psgconf->data_obj('inetd')->insert( { 'printer/tcp' => { server => "/usr/lib/print/in.lpd" } } ) if (!defined $psgconf->data_obj('inetd')->find('printer/tcp')); } sub _enable_rc_scripts { my ($self, $psgconf) = @_; my ($daemon); return if ( $psgconf->data_obj('print_enable')->equals('false') ); foreach $daemon ( @{$psgconf->data_obj('print_daemons')->get()} ) { $psgconf->data_obj('rc_scripts')->insert( { $daemon => { 'state' => 'enable' }} ); } } ############################################################################### ### decide() method ############################################################################### sub decide { my ($self, $psgconf) = @_; my ($print_subsystem_type); return if ( $psgconf->data_obj('print_enable')->equals('false') ); if ($psgconf->data_obj('print_subsystem_type')->equals('printcap')) { $psgconf->register_actions( PSGConf::Action::GenerateFile::printcap->new( 'name' => '/etc/printcap', 'default_printer' => $psgconf->data_obj('default_printer')->get(), 'printers' => $psgconf->data_obj('printers')->get() ) ); } # elsif ($psgconf->data_obj('print_subsystem_type')->equals('cups')) # { # } elsif ($psgconf->data_obj('print_subsystem_type')->equals('SysV')) { $psgconf->register_actions( PSGConf::Action::svcs::import->new( name => 'Import Print Server SMF configurations', FMRI => 'svc:/application/print/server:default', manifest => '/var/svc/manifest/application/print/server.xml' ), PSGConf::Action::svcs::import->new( name => 'Import Print Daemon SMF configurations', FMRI => 'svc:/application/print/rfc1179:default', manifest => '/var/svc/manifest/application/print/rfc1179.xml' ) ) if ($psgconf->data_obj('platform')->match('solaris10')); my ($printers) = $psgconf->data_obj('printers')->get(); $psgconf->register_actions( map { PSGConf::Action::lpadmin->new( name => $_, default_printer => $psgconf->data_obj('default_printer')->get(), remotehost => $printers->{$_}->{remotehost}, device => $printers->{$_}->{device}, model => $printers->{$_}->{model}, protocol => $printers->{$_}->{protocol}, options => $printers->{$_}->{options}, content_type => $printers->{$_}->{content_type} ) } sort keys %{$printers} ); } } ############################################################################### ### Constructor ############################################################################### sub new { my ($class, $psgconf) = @_; my ($self); $self = {}; bless($self, $class); ### So that _add_pkgs knows which directives to look at $self->{name} = 'print'; $self->{enable} = $self->{name} . '_enable'; $self->{packages} = $self->{name} . '_packages'; $self->{syslog} = 'print'; $self->{facility} = 'lpr.info'; $psgconf->register_data( print_enable => PSGConf::Data::Boolean->new( value => 'false' ), print_subsystem_type => PSGConf::Data::String->new( value => 'printcap' ), default_printer => PSGConf::Data::String->new(), print_packages => PSGConf::Data::List->new(), print_daemons => PSGConf::Data::List->new(), printers => PSGConf::Data::Hash->new( value_type => 'HASH' ), ); $psgconf->register_policy($self, print_enable_rc_scripts => '_enable_rc_scripts', print_add_packages => '_add_pkgs', print_add_syslog => '_add_syslog', print_add_inetd_entry => '_policy_add_inetd_entry' ); return $self; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Control::Printers - psgconf control class for printer configuration =head1 SYNOPSIS In F: Control PSGConf::Control::Printers =head1 DESCRIPTION The B module provides a B control object for configuring printer files, including B. It supports the following methods: =over 4 =item new() The constructor. Its parameter is a reference to the B object. It registers the following Data objects: =over 4 =item I A B object that indicates whether the printers should be configured. The default is off. =item I A B object that lists all packages to install. =item I A B object that indicates what type of printing subsystem is being configured. Currently, the only supported value is C and C; other values will be added in the future. =item I A B object that indicates the name of the default printer. =item I A B object that contains the entries for each printer. The hash key is the name of the print queue, and the hash value is an anonymous hash containing the settings for that print queue. The following settings are supported: =over 4 =item I The name of the host the printer is attached to. =item I The name of the queue on the remote host. =item I A description of the printer. =item I The location to store the intermediate print files before sending to the I. =item I The location to log print request and results. =item I Any other options that are needed for the queue setup. =back =back In addition, the constructor registers the following policy method: =over 4 =item I Updates the I data object (provided by the B module) to enable the printer daemon, based on whether the I data object is true. =back =item decide() If I is true and I is set to C, instantiates a B object to generate the F file. =back =head1 BUGS This module only implements the client side of printing. Printing subsystems other than C should be supported. =head1 SEE ALSO L printcap(5) L L L L L L L L L L =cut