diff options
Diffstat (limited to 'perl-install/services.pm')
-rw-r--r-- | perl-install/services.pm | 18 |
1 files changed, 18 insertions, 0 deletions
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; } |