aboutsummaryrefslogtreecommitdiffstats
path: root/del-service
diff options
context:
space:
mode:
Diffstat (limited to 'del-service')
-rwxr-xr-xdel-service21
1 files changed, 20 insertions, 1 deletions
diff --git a/del-service b/del-service
index f519065..6051808 100755
--- a/del-service
+++ b/del-service
@@ -39,13 +39,32 @@ else
shift 2
fi
units="$*" # systemd units
-units_to_remove=
# If only a sysvinit service is given, then deal with a systemd unit of the same
# name. Specific specs can enable specific unit names as needed but this should
# catch the most common usage.
if [ -z "$units" ]; then
units="$srv.service"
+
+ # We need to normalise the systemd unit name as the native unit may not have
+ # the same filename (sans it's .service suffix) as sysvinit script.
+ # In this case, symlinks are used to mask the sysvinit file, but for enabling
+ # and disabling units we must use the official name.
+ SYSTEMUNITDIR=/lib/systemd/system
+ USERUNITDIR=/etc/systemd/system
+ RUNTIMEUNITDIR=/run/systemd/system
+
+ searchunit=
+ if [ -f "$SYSTEMUNITDIR/$units" ]; then
+ searchunit=$(/usr/bin/readlink "$SYSTEMUNITDIR/$units")
+ elif [ -f "$USERUNITDIR/$units" ]; then
+ searchunit=$(/usr/bin/readlink "$USERUNITDIR/$units")
+ elif [ -f "$RUNTIMEUNITDIR/$units" ]; then
+ searchunit=$(/usr/bin/readlink "$RUNTIMEUNITDIR/$units")
+ fi
+ if [ -n "$searchunit" ]; then
+ units=$searchunit
+ fi
fi
if [ $num = 0 ]; then