summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/services.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-11-12 12:05:40 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-11-12 12:05:40 +0000
commit046406ab6b13659f4be843d3d2d5639efaf425fe (patch)
tree2304d9911b495ea5262815f2b3cca305f53d83f4 /perl-install/printer/services.pm
parent57582cf77904240eee6c29874866b9d62e4a9951 (diff)
downloaddrakx-backup-do-not-use-046406ab6b13659f4be843d3d2d5639efaf425fe.tar
drakx-backup-do-not-use-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.gz
drakx-backup-do-not-use-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.bz2
drakx-backup-do-not-use-046406ab6b13659f4be843d3d2d5639efaf425fe.tar.xz
drakx-backup-do-not-use-046406ab6b13659f4be843d3d2d5639efaf425fe.zip
printer related modules cleaning :
- create the printer/ hierarchy - split services related stuff into services.pm & printer::services, - move things that've nothing to do with printers into common.pm (alternatives, permissions, ...) - move eveything related to cups, gimp-print, detection, {star,open}office to the corresponding splited printer:: module - big consolidation of printer::office (it was obvious there were tons of duplication between staroffice and openoffice managment) - move other stuff into printer::main, printer::common, status : print.pm has been heavily splited (now one can begin to understand the little bits). printerdrake still needs to be splited/cleaned and eventually removed since printer/printerdrake modules separation is not understandable by other people till, in printer::gimp, $lprcommand is neither declared nor setted nowhere. idem in mdk9.0 ...
Diffstat (limited to 'perl-install/printer/services.pm')
-rw-r--r--perl-install/printer/services.pm61
1 files changed, 61 insertions, 0 deletions
diff --git a/perl-install/printer/services.pm b/perl-install/printer/services.pm
new file mode 100644
index 000000000..1b68da96a
--- /dev/null
+++ b/perl-install/printer/services.pm
@@ -0,0 +1,61 @@
+package printer::services;
+
+use strict;
+use services;
+use run_program;
+
+sub restart ($) {
+ my ($service) = @_;
+ if (services::restart($service)) {
+ # CUPS needs some time to come up.
+ wait_for_cups() if $service eq "cups";
+ return 1;
+ } else { return 0 }
+}
+
+sub start ($) {
+ my ($service) = @_;
+ if (services::start($service)) {
+ # CUPS needs some time to come up.
+ wait_for_cups() if $service eq "cups";
+ return 1;
+ } else { return 0 }
+}
+
+sub start_not_running_service ($) {
+ my ($service) = @_;
+ # The exit status is not zero when the service is not running
+ if (services::start_not_running_service($service)) {
+ return 0;
+ } else {
+ run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", "start");
+ if (($? >> 8) != 0) {
+ return 0;
+ } else {
+ # CUPS needs some time to come up.
+ wait_for_cups() if $service eq "cups";
+ return 1;
+ }
+ }
+}
+
+sub wait_for_cups {
+ # CUPS needs some time to come up. Wait up to 30 seconds, checking
+ # whether CUPS is ready.
+ my $cupsready = 0;
+ my $i;
+ for ($i = 0; $i < 30; $i++) {
+ run_program::rooted($::prefix, "/usr/bin/lpstat", "-r");
+ if (($? >> 8) != 0) {
+ # CUPS is not ready, continue
+ sleep 1;
+ } else {
+ # CUPS is ready, quit
+ $cupsready = 1;
+ last;
+ }
+ }
+ return $cupsready;
+}
+
+1;