From 0ed0f5c5d226551186365fc41cc94dfdef8f9a57 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 23 May 2012 18:25:15 +0000 Subject: (systemd_unit_exists) factorize --- perl-install/services.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'perl-install/services.pm') diff --git a/perl-install/services.pm b/perl-install/services.pm index 6eab201be..cef49bb5a 100644 --- a/perl-install/services.pm +++ b/perl-install/services.pm @@ -433,7 +433,7 @@ sub _legacy_services() { if (my ($name, $l) = m!^(\S+)\s+(0:(on|off).*)!) { # If we expect to use systemd (i.e. installer) only show those # sysvinit scripts which are not masked by a native systemd unit. - my $has_systemd_unit = (-e "$::prefix/lib/systemd/system/$name.service" or -l "$::prefix/lib/systemd/system/$name.service"); + my $has_systemd_unit = systemd_unit_exists($name); if (!$has_systemd || !$has_systemd_unit) { if ($::isInstall) { $on_off = $l =~ /\d+:on/g; @@ -466,12 +466,14 @@ sub services() { - - +sub systemd_unit_exists { + my ($name) = @_; + -e "$::prefix/lib/systemd/system/$name.service" or -l "$::prefix/lib/systemd/system/$name.service"; +} sub service_exists { my ($service) = @_; - -x "$::prefix/etc/rc.d/init.d/$service" or -e "$::prefix/lib/systemd/system/$service.service" or -l "$::prefix/lib/systemd/system/$service.service"; + -x "$::prefix/etc/rc.d/init.d/$service" or systemd_unit_exists($service); } sub restart ($) { -- cgit v1.2.1