summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-07-26 09:09:21 +0000
committerColin Guthrie <colin@mageia.org>2012-07-26 09:09:21 +0000
commit169180cb11f798ae4abc26846bf8c4fbac27470f (patch)
treea24b56c9d31a87b1f34ab2413889f511892b7c36
parent29bb0f29336671219463eeef26f9f404f2833f0a (diff)
downloaddrakx-169180cb11f798ae4abc26846bf8c4fbac27470f.tar
drakx-169180cb11f798ae4abc26846bf8c4fbac27470f.tar.gz
drakx-169180cb11f798ae4abc26846bf8c4fbac27470f.tar.bz2
drakx-169180cb11f798ae4abc26846bf8c4fbac27470f.tar.xz
drakx-169180cb11f798ae4abc26846bf8c4fbac27470f.zip
drakxservices: when listing services ensure disabled services that can be enabled are shown (mga#6843)
-rw-r--r--perl-install/NEWS4
-rw-r--r--perl-install/services.pm18
2 files changed, 22 insertions, 0 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index e935117df..1cf44c1ee 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,3 +1,7 @@
+- drakxservices:
+ o when listing services ensure disabled services that can be enabled are
+ shown (mga#6843)
+
Version 14.31 - 24 July 2012
- drakauth: don't update UsePAM option in sshd configuration
diff --git a/perl-install/services.pm b/perl-install/services.pm
index 6927b71b8..0b1359af2 100644
--- a/perl-install/services.pm
+++ b/perl-install/services.pm
@@ -372,6 +372,7 @@ sub xinetd_services() {
sub _systemd_services() {
local $ENV{LANGUAGE} = 'C';
my @services;
+ my %loaded;
# Running system using systemd
log::explanations("Detected systemd running. Using systemctl introspection.");
foreach (run_program::rooted_get_stdout($::prefix, '/bin/systemctl', '--full', '--all', 'list-units')) {
@@ -381,9 +382,26 @@ sub _systemd_services() {
# also handled by systemd
if ($name !~ /.*\@$/g && (-e "$::prefix/lib/systemd/system/$name.service" or -e "$::prefix/etc/rc.d/init.d/$name") && ! -l "$::prefix/lib/systemd/system/$name.service") {
push @services, [ $name, !!run_program::rooted($::prefix, '/bin/systemctl', '--quiet', 'is-enabled', "$name.service") ];
+ $loaded{$name} = 1;
}
}
}
+ # list-units will not list disabled units that can be enabled
+ foreach (run_program::rooted_get_stdout($::prefix, '/bin/systemctl', '--full', 'list-unit-files')) {
+ if (my ($name) = m!^(\S+)\.service\s+disabled!) {
+ # We only look at non-template, non-linked service files in /lib
+ # We also check for any non-masked sysvinit files as these are
+ # also handled by systemd
+ if (!exists $loaded{$name} && $name !~ /.*\@$/g && (-e "$::prefix/lib/systemd/system/$name.service" or -e "$::prefix/etc/rc.d/init.d/$name") && ! -l "$::prefix/lib/systemd/system/$name.service") {
+ # Limit ourselves to "standard" targets which can be enabled
+ my $wantedby = cat_("$::prefix/lib/systemd/system/$name.service") =~ /^WantedBy=(graphical|multi-user).target$/sm ? $1 : '';
+ if ($wantedby) {
+ push @services, [ $name, 0 ];
+ }
+ }
+ }
+ }
+
@services;
}