summaryrefslogtreecommitdiffstats
path: root/perl-install/services.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/services.pm')
-rw-r--r--perl-install/services.pm98
1 files changed, 60 insertions, 38 deletions
diff --git a/perl-install/services.pm b/perl-install/services.pm
index 6e838cc05..319e4ff49 100644
--- a/perl-install/services.pm
+++ b/perl-install/services.pm
@@ -1,4 +1,4 @@
-package services;
+package services; # $Id$
use diagnostics;
use strict;
@@ -10,18 +10,18 @@ use common qw(:common :functional :system :file);
use commands;
use run_program;
-my %services = (
+sub description {
+ my %services = (
anacron => __("Anacron a periodic command scheduler."),
-apmd => __("apmd is used for monitoring batery status and logging it via
-syslog(8). It can also be used for shutting down the machine when the battery is
-low."),
+apmd => __("apmd is used for monitoring batery status and logging it via syslog.
+It can also be used for shutting down the machine when the battery is low."),
atd => __("Runs commands scheduled by the at command at the time specified when
at was run, and runs batch commands when the load average is low enough."),
crond => __("cron is a standard UNIX program that runs user-specified programs
at periodic scheduled times. vixie cron adds a number of features to the basic
UNIX cron, including better security and more powerful configuration options."),
gpm => __("GPM adds mouse support to text-based Linux applications such the
-Midnight Commander. Is also allows mouse-based console cut-and-paste operations,
+Midnight Commander. It also allows mouse-based console cut-and-paste operations,
and includes support for pop-up menus on the console."),
httpd => __("Apache is a World Wide Web server. It is used to serve HTML files
and CGI."),
@@ -30,8 +30,8 @@ variety of other internet services as needed. It is responsible for starting
many services, including telnet, ftp, rsh, and rlogin. Disabling inetd disables
all of the services it is responsible for."),
keytable => __("This package loads the selected keyboard map as set in
-/etc/sysconfig/keyboard. This can be selected using the kbdconfig utility. You
-should leave this enabled for most machines."),
+/etc/sysconfig/keyboard. This can be selected using the kbdconfig utility.
+You should leave this enabled for most machines."),
lpd => __("lpd is the print daemon required for lpr to work properly. It is
basically a server that arbitrates print jobs to printer(s)."),
named => __("named (BIND) is a Domain Name Server (DNS) that is used to resolve
@@ -57,7 +57,7 @@ random => __("Saves and restores system entropy pool for higher quality random
number generation."),
routed => __("The routed daemon allows for automatic IP router table updated via
the RIP protocol. While RIP is widely used on small networks, more complex
-routing protocls are needed for complex networks."),
+routing protocols are needed for complex networks."),
rstatd => __("The rstat protocol allows users on a network to retrieve
performance metrics for any machine on that network."),
rusersd => __("The rusers protocol allows users on a network to identify who is
@@ -68,40 +68,62 @@ syslog => __("Syslog is the facility by which many daemons use to log messages
to various system log files. It is a good idea to always run syslog."),
usb => __("This startup script try to load your modules for your usb mouse."),
xfs => __("Starts and stops the X Font Server at boot time and shutdown."),
-);
+ );
+ my ($name, $prefix) = @_;
+ my $s = $services{$name};
+ if ($s) {
+ $s = translate($s);
+ } else {
+ ($s = cat_("$prefix/etc/rc.d/init.d/$_")) =~ s/\\\s*\n#\s*//mg;
+ ($s) = $s =~ /^# description:\s+(.*?)^(?:[^#]|# {0,2}\S)/sm;
+ $s =~ s/^#\s*//m;
+ }
+ $s =~ s/\n/ /gm; $s =~ s/\s+$//;
+ $s;
+}
-sub drakxservices {
- my ($in, $prefix) = @_;
+#- returns:
+#--- the listref of installed services
+#--- the listref of "on" services
+sub services {
+ my ($prefix) = @_;
my $cmd = $prefix ? "chroot $prefix" : "";
- my @services = map { [/(\S+)/, /:on/ ] } sort `$cmd chkconfig --list`;
- my @l = map { $_->[0] } @services;
- my @before = map { $_->[1] } @services;
- my @descr = map {
- my $s = $services{$_};
- if ($s) {
- $s = translate($s);
- } else {
- ($s = cat_("$prefix/etc/rc.d/init.d/$_")) =~ s/\\\s*\n#\s*//mg;
- ($s) = $s =~ /^# description:\s+(.*?)^(?:[^#]|# {0,2}\S)/sm;
- $s =~ s/^#\s*//m;
- }
- $s =~ s/\n/ /gm; $s =~ s/\s+$//;
- $s;
- } @l;
+ my @l = map { [ /([^\s:]+)/, /\bon\b/ ] } grep { !/:$/ } sort `LANGUAGE=C $cmd chkconfig --list`;
+ [ map { $_->[0] } @l ], [ mapgrep { $_->[1], $_->[0] } @l ];
+}
- my $after = $in->ask_many_from_list_with_help("drakxservices",
- _("Choose which services should be automatically started at boot time"),
- \@l, \@descr, \@before) or return;
+sub ask {
+ my ($in, $prefix) = @_;
+ my ($l, $on_services) = services($prefix);
+ $in->ask_many_from_list("drakxservices",
+ _("Choose which services should be automatically started at boot time"),
+ {
+ list => $l,
+ help => sub { description($_, $prefix) },
+ values => $on_services,
+ sort => 1,
+ });
+}
- mapn {
- my ($name, $before, $after) = @_;
+sub doit {
+ my ($in, $on_services, $prefix) = @_;
+ my ($l, $was_on_services) = services($prefix);
+
+ foreach (@$l) {
+ my $before = member($_, @$was_on_services);
+ my $after = member($_, @$on_services);
if ($before != $after) {
- run_program::rooted($prefix, "chkconfig", $after ? "--add" : "--del", $name);
- if ($after && cat_("$prefix/etc/rc.d/init.d/$name") =~ /^#\s+chkconfig:\s+-/m) {
- #- `/sbin/runlevel` =~ /\s(\d+)/ or die "bad runlevel";
- #- $1 == 3 || $1 == 5 or log::l("strange runlevel: ``$1'' (neither 3 nor 5)");
- run_program::rooted($prefix, "chkconfig", "--level", "35", $name, "on");
+ my $script = "/etc/rc.d/init.d/$_";
+ run_program::rooted($prefix, "chkconfig", $after ? "--add" : "--del", $_);
+ if ($after && cat_("$prefix$script") =~ /^#\s+chkconfig:\s+-/m) {
+ run_program::rooted($prefix, "chkconfig", "--level", "35", $_, "on");
+ }
+ if (!$after && $::isStandalone) {
+ run_program::rooted($prefix, $script, "stop");
}
}
- } \@l, \@before, $after;
+ }
}
+
+
+1;