From 24f6b3a13869919c8e1b4d9734a188b62e8d6240 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 13 Aug 2012 10:35:05 +0000 Subject: drakxservices: when listing services ensure disabled services that can be enabled are shown (mga#6843) (backported from trunk) --- perl-install/NEWS | 3 +++ perl-install/services.pm | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/perl-install/NEWS b/perl-install/NEWS index 5f03e6081..fc5ca5d79 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,4 +1,7 @@ - drakauth: don't update UsePAM option in sshd configuration +- drakxservices: + o when listing services ensure disabled services that can be enabled are + shown (mga#6843) Version 14.21 - 11 May 2012 diff --git a/perl-install/services.pm b/perl-install/services.pm index 6eab201be..31047e624 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; } -- cgit v1.2.1