summaryrefslogtreecommitdiffstats
path: root/perl-install/printer.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2001-08-05 00:39:39 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2001-08-05 00:39:39 +0000
commit814ebdbbb3d4c7b02ab1746c57df605ff443ea27 (patch)
tree2567d670ae0b23c7d44ff9394c48ca782c275fbe /perl-install/printer.pm
parent8ce6cf5c815c0ccb996cdd325a3dc6b57c97f2e8 (diff)
downloaddrakx-814ebdbbb3d4c7b02ab1746c57df605ff443ea27.tar
drakx-814ebdbbb3d4c7b02ab1746c57df605ff443ea27.tar.gz
drakx-814ebdbbb3d4c7b02ab1746c57df605ff443ea27.tar.bz2
drakx-814ebdbbb3d4c7b02ab1746c57df605ff443ea27.tar.xz
drakx-814ebdbbb3d4c7b02ab1746c57df605ff443ea27.zip
Automatic installation and start of the desired printer spooler
Diffstat (limited to 'perl-install/printer.pm')
-rw-r--r--perl-install/printer.pm42
1 files changed, 35 insertions, 7 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 59f4ce9a0..bf98ddc3d 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -1,9 +1,8 @@
package printer;
# $Id$
-
-
-
+#use diagnostics;
+#use strict;
use common;
@@ -14,9 +13,11 @@ use run_program;
my $prefix = "";
#-location of the printer database in an installed system
-my $PRINTER_DB_FILE = "/usr/share/foomatic/db/compiled/overview.xml";
+my $PRINTER_DB_FILE = "/usr/share/foomatic/db/compiled/overview.xml";
+#-configuration directory of Foomatic
+my $FOOMATICCONFDIR = "/etc/foomatic";
#-location of the file containing the default spooler's name
-my $FOOMATIC_DEFAULT_SPOOLER = "/etc/foomatic/defaultspooler";
+my $FOOMATIC_DEFAULT_SPOOLER = "$FOOMATICCONFDIR/defaultspooler";
%spooler = (
__("CUPS - Common Unix Printing System") => "cups",
@@ -72,11 +73,38 @@ sub get_default_spooler () {
sub set_default_spooler ($) {
my ($printer) = @_;
- open DEFSPOOL, "> $prefix$FOOMATIC_DEFAULT_SPOOLER";
+ # Make Foomatic config directory if it does not exist yet
+ if (!(-d $FOOMATICCONFDIR)) {mkdir $FOOMATICCONFDIR;}
+ # Mark the default driver in a file
+ open DEFSPOOL, "> $prefix$FOOMATIC_DEFAULT_SPOOLER" ||
+ die "Cannot create $prefix$FOOMATIC_DEFAULT_SPOOLER!";
print DEFSPOOL $printer->{SPOOLER};
close DEFSPOOL;
}
+sub restart_service ($) {
+ my ($service) = @_;
+ run_program::rooted($prefix, "/etc/rc.d/init.d/$service restart")
+ || die "Could not restart $service!";
+}
+
+sub start_service ($) {
+ my ($service) = @_;
+ run_program::rooted($prefix, "/etc/rc.d/init.d/$service start")
+ || die "Could not start $service!";
+}
+
+sub stop_service ($) {
+ my ($service) = @_;
+ run_program::rooted($prefix, "/etc/rc.d/init.d/$service stop")
+ || die "Could not stop $service!";
+}
+
+sub remove_package ($) {
+ my ($package) = @_;
+ run_program::rooted($prefix, "rpm -e --nodeps $package") || do {};
+}
+
sub copy_printer_params($$) {
my ($from, $to) = @_;
map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from;
@@ -609,7 +637,7 @@ sub restart_queue($) {
for ($printer->{SPOOLER}) {
/cups/ && do {
#- restart cups.
- run_program::rooted($prefix, "/etc/rc.d/init.d/cups start"); sleep 1;
+ run_program::rooted($prefix, "/etc/rc.d/init.d/cups restart"); sleep 1;
last };
/lpr|lprng/ && do {
#- restart lpd.