aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/del-service
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/del-service')
-rwxr-xr-xtrunk/del-service92
1 files changed, 92 insertions, 0 deletions
diff --git a/trunk/del-service b/trunk/del-service
new file mode 100755
index 0000000..82c2520
--- /dev/null
+++ b/trunk/del-service
@@ -0,0 +1,92 @@
+#!/bin/sh
+#---------------------------------------------------------------
+# Project : Mandriva Linux
+# Module : rpm-helper
+# File : del-service
+# Version : $Id$
+# Authors : Frederic Lepied, Andrey Borzenkov
+# Created On : Tue Jul 9 08:11:26 2002
+# Purpose : helper script for rpm scriptlets to remove a
+# service.
+#---------------------------------------------------------------
+
+if [ x$1 = x--no-sysv ]; then
+ do_sysv=no
+ shift
+else
+ do_sysv=yes
+fi
+
+if [ $# -lt 3 ]; then
+ echo "usage: $0 [--no-sysv] <pkg name> <number installed> [<service name>] [<unit name> ...]" 1>&2
+ exit 1
+fi
+
+# What init system are we currently using?
+if /bin/mountpoint -q /sys/fs/cgroup/systemd; then
+ init=systemd
+else
+ init=sysvinit
+fi
+
+pkg=$1 # name of the package
+num=$2 # number of packages installed
+if [ $do_sysv = yes ]; then
+ srv=$3 # name of the SysV script
+ shift 3
+else
+ srv=
+ shift 2
+fi
+units="$*" # systemd units
+
+# 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
+
+ if [ -z "$DURING_INSTALL" ]; then
+ if [ x$init = xsystemd ]; then
+ /bin/systemctl stop $units
+ elif [ -n "srv" ]; then
+ /sbin/service $srv stop > /dev/null || :
+ fi
+ fi
+
+ /bin/systemctl --no-reload --quiet disable $units >/dev/null
+ [ -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 -f /etc/rc.d/init.d/$srv -a x$init = xsystemd ]; then
+ /bin/rm -f /etc/rc.d/init.d/$srv
+ /bin/systemctl daemon-reload
+ fi
+fi
+
+# del-service ends here