summaryrefslogtreecommitdiffstats
path: root/perl-install/services.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2020-09-15 11:03:52 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2020-09-15 11:03:52 +0100
commit29e2fa03969ce6c30217693df27e2d5c7b38267e (patch)
treefc97b868bce84fd15a00c8fe61cbd7d6a826291f /perl-install/services.pm
parent42ae062bd55b9d39324e75573a749b68337f0f1d (diff)
downloaddrakx-29e2fa03969ce6c30217693df27e2d5c7b38267e.tar
drakx-29e2fa03969ce6c30217693df27e2d5c7b38267e.tar.gz
drakx-29e2fa03969ce6c30217693df27e2d5c7b38267e.tar.bz2
drakx-29e2fa03969ce6c30217693df27e2d5c7b38267e.tar.xz
drakx-29e2fa03969ce6c30217693df27e2d5c7b38267e.zip
Include systemd sockets and timers in lists returned by services::services().
Diffstat (limited to 'perl-install/services.pm')
-rw-r--r--perl-install/services.pm38
1 files changed, 24 insertions, 14 deletions
diff --git a/perl-install/services.pm b/perl-install/services.pm
index 95e068770..69de0cb00 100644
--- a/perl-install/services.pm
+++ b/perl-install/services.pm
@@ -24,6 +24,13 @@ sub _base_name {
$service =~ s/\.(service|socket|timer)$//;
}
+#- The name used in the lists returned by services(). For backwards compatibility,
+#- use just the base name for .service units.
+sub _list_name {
+ my ($name, $type) = @_;
+ $type eq 'service' ? $name : "$name.$type";
+}
+
sub description {
my %services = (
acpid => N_("Listen and dispatch ACPI events from the kernel"),
@@ -379,29 +386,31 @@ sub _systemd_services() {
# even if systemd is not running, we can detect status of shorewell service which is not wanted by:
my @opts = $::isInstall ? 'list-unit-files' : qw(--all --plain list-units);
foreach (run_program::rooted_get_stdout($::prefix, '/bin/systemctl', '--no-legend', '--no-pager', '--full', @opts)) {
- my ($name) = m!^(\S+)\.service\s+loaded!;
- ($name) = m!^(\S+)\.service\s+enabled! if $::isInstall && !$name;
+ my ($name, $type) = m!^(\S+)\.(service|socket|timer)\s+loaded!;
+ ($name, $type) = m!^(\S+)\.(service|socket|timer)\s+enabled! if $::isInstall && !$name;
+ my $unit_name = "$name.$type";
if ($name) {
# 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 ($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;
+ if ($name !~ /.*\@$/g && (-e "$::prefix/lib/systemd/system/$unit_name" or -e "$::prefix/etc/rc.d/init.d/$name") && ! -l "$::prefix/lib/systemd/system/$unit_name") {
+ push @services, [ _list_name($name, $type), !!run_program::rooted($::prefix, '/bin/systemctl', '--quiet', 'is-enabled', "$unit_name") ];
+ $loaded{$unit_name} = 1;
}
}
}
# list-units will not list disabled units that can be enabled
foreach (run_program::rooted_get_stdout($::prefix, '/bin/systemctl', '--no-legend', '--no-pager', '--full', 'list-unit-files')) {
- if (my ($name) = m!^(\S+)\.service\s+disabled!) {
+ if (my ($name, $type) = m!^(\S+)\.(service|socket|timer)\s+disabled!) {
+ my $unit_name = "$name.$type";
# 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") {
+ if (!exists $loaded{$unit_name} && $name !~ /.*\@$/g && (-e "$::prefix/lib/systemd/system/$unit_name" or -e "$::prefix/etc/rc.d/init.d/$name") && ! -l "$::prefix/lib/systemd/system/$unit_name") {
# 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 : '';
+ my $wantedby = cat_("$::prefix/lib/systemd/system/$unit_name") =~ /^WantedBy=(graphical|multi-user).target$/sm ? $1 : '';
if ($wantedby) {
- push @services, [ $name, 0 ];
+ push @services, [ _list_name($name, $type), 0 ];
}
}
}
@@ -421,11 +430,12 @@ sub _legacy_services() {
# combine that with information from chkconfig regarding legacy sysvinit
# scripts (which systemd will parse and include when running)
log::explanations("Detected systemd installed. Using fake service+chkconfig introspection.");
- foreach (glob_("$::prefix/lib/systemd/system/*.service")) {
- my ($name) = m!([^/]*).service$!;
+ foreach (glob("$::prefix/lib/systemd/system/*.{service,socket,timer}")) {
+ my ($name, $type) = m!([^/]*)\.(service|socket|timer)$!;
+ my $unit_name = "$name.$type";
# We only look at non-template, non-symlinked service files
- if (!(/.*\@\.service$/g) && ! -l $_) {
+ if ($name !~ /.*\@$/g && ! -l $_) {
# Limit ourselves to "standard" targets
my $wantedby = cat_($_) =~ /^WantedBy=(graphical|multi-user).target$/sm ? $1 : '';
if ($wantedby) {
@@ -435,8 +445,8 @@ sub _legacy_services() {
# setup where -e will fail if the symlink target does
# exist which is typically the case when viewed outside
# of the chroot.
- if (!-l "$::prefix/lib/systemd/system/$wantedby.target.wants/$name.service") {
- push @services, [ $name, !!-l "$::prefix/etc/systemd/system/$wantedby.target.wants/$name.service" ];
+ if (!-l "$::prefix/lib/systemd/system/$wantedby.target.wants/$unit_name") {
+ push @services, [ _list_name($name, $type), !!-l "$::prefix/etc/systemd/system/$wantedby.target.wants/$unit_name" ];
}
}
}