diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-12 12:05:40 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-12 12:05:40 +0000 |
commit | 046406ab6b13659f4be843d3d2d5639efaf425fe (patch) | |
tree | 2304d9911b495ea5262815f2b3cca305f53d83f4 /perl-install/services.pm | |
parent | 57582cf77904240eee6c29874866b9d62e4a9951 (diff) | |
download | drakx-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/services.pm')
-rw-r--r-- | perl-install/services.pm | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/perl-install/services.pm b/perl-install/services.pm index c48518816..3348b2bf6 100644 --- a/perl-install/services.pm +++ b/perl-install/services.pm @@ -1,11 +1,16 @@ package services; # $Id$ -use diagnostics; -use strict; + + #-###################################################################################### #- misc imports #-###################################################################################### + +use strict; +use common; +use run_program; + use common; use run_program; @@ -226,7 +231,7 @@ sub ask_standalone_gtk { push @$on_services, $service if !member($service, @$on_services); } else { @$on_services = grep { $_ ne $service } @$on_services; - } }), member($service, @$on_services))), + }}), member($service, @$on_services))), map { my $a = $_; gtkpack__(new Gtk::HBox(0,0), gtksignal_connect(new Gtk::Button(translate($a)), clicked => sub { my $c = "service $service " . (lc($a) eq "start" ? "restart" : lc($a)) . " 2>&1"; local $_ = `$c`; s/\033\[[^mG]*[mG]//g; @@ -286,4 +291,80 @@ sub services { [ map { $_->[0] } @l ], [ map { $_->[0] } grep { $_->[1] } @l ]; } + + + + + +# the following functions are mostly by printer related modules + +#-if we are in an DrakX config +our $prefix = ""; + + +sub restart ($) { + my ($service) = @_; + # Exit silently if the service is not installed + return 1 if !(-x "$prefix/etc/rc.d/init.d/$service"); + run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "restart"); +} + +sub start ($) { + my ($service) = @_; + # Exit silently if the service is not installed + return 1 if !(-x "$prefix/etc/rc.d/init.d/$service"); + run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "start"); + return (($? >> 8) != 0) ? 0 : 1; +} + +sub start_not_running_service ($) { + my ($service) = @_; + # Exit silently if the service is not installed + return 1 if !(-x "$prefix/etc/rc.d/init.d/$service"); + run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "status"); + return (($? >> 8) != 0) ? 0 : 1; +} + +sub stop ($) { + my ($service) = @_; + # Exit silently if the service is not installed + return 1 if !(-x "$prefix/etc/rc.d/init.d/$service"); + run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "stop"); + return (($? >> 8) != 0) ? 0 : 1; +} + +sub is_service_running ($) { + my ($service) = @_; + # Exit silently if the service is not installed + return 0 if !(-x "$prefix/etc/rc.d/init.d/$service"); + run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "status"); + # The exit status is not zero when the service is not running + return (($? >> 8) != 0) ? 0 : 1; +} + +sub starts_on_boot ($) { + my ($service) = @_; + local *F; + open F, ($::testing ? $prefix : "chroot $prefix/ ") . + "/bin/sh -c \"export LC_ALL=C; /sbin/chkconfig --list $service 2>&1\" |" or + return 0; + while (my $line = <F>) { + chomp $line; + if ($line =~ /:on/) { + close F; + return 1; + } + } + close F; + return 0; +} + +sub start_service_on_boot ($) { + my ($service) = @_; + run_program::rooted($prefix, "/sbin/chkconfig", "--add", $service) + or return 0; + return 1; +} + + 1; |