aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadd-service11
-rwxr-xr-xdel-service12
2 files changed, 18 insertions, 5 deletions
diff --git a/add-service b/add-service
index 09e549d..23b0094 100755
--- a/add-service
+++ b/add-service
@@ -18,7 +18,7 @@ else
fi
if [ $# -lt 3 ]; then
- echo "usage: $0 [--no-sysv] <pkg name> <number installed> [<service name>] <unit name> ..." 1>&2
+ echo "usage: $0 [--no-sysv] <pkg name> <number installed> [<service name>] [<unit name> ...]" 1>&2
exit 1
fi
@@ -34,6 +34,13 @@ fi
units="$*" # systemd units
units_to_enable= # units enabled by msec
+# 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"
+fi
+
add_chkconfig_service() {
if [ -n "$units_to_enable" ]; then
/bin/systemctl --quiet enable $units_to_enable
@@ -125,7 +132,7 @@ else
/sbin/chkconfig --add $srv
fi
- if [ -z "$units" ] || ! /bin/mountpoint -q /sys/fs/cgroup/systemd; then
+ if ! /bin/mountpoint -q /sys/fs/cgroup/systemd; then
# restart the service if already running
if [ -f /var/lock/subsys/$srv ]; then
/sbin/service $srv restart > /dev/null || :
diff --git a/del-service b/del-service
index c19b1f2..753fcc3 100755
--- a/del-service
+++ b/del-service
@@ -18,7 +18,7 @@ else
fi
if [ $# -lt 3 ]; then
- echo "usage: $0 [--no-sysv] <pkg name> <number installed> [<service name>] <unit name> ..." 1>&2
+ echo "usage: $0 [--no-sysv] <pkg name> <number installed> [<service name>] [<unit name> ...]" 1>&2
exit 1
fi
@@ -34,6 +34,12 @@ 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"
+fi
if [ $num = 0 ]; then
@@ -47,14 +53,14 @@ if [ $num = 0 ]; then
fi
fi
- [ -n "$units" ] && /bin/systemctl --no-reload --quiet disable $units
+ /bin/systemctl --no-reload --quiet disable $units
[ -n "$srv" ] && /sbin/chkconfig --del $srv
# Yes - this is very ugly workaround. chkconfig --del does daemon-reload,
# but initscript is still there, so it remains loaded. Remove file and
# reload again. Systemd units are supposed to provide postun script
- if [ -n "$srv" -a -z "$units" ] && \
+ if [ -n "$srv" -a -f /etc/rc.d/init.d/$srv ] && \
/bin/mountpoint -q /sys/fs/cgroup/systemd; then
/bin/rm -f /etc/rc.d/init.d/$srv
/bin/systemctl daemon-reload