From 606ae7d18503eb8d92b3af0cb21059b6ba0594ee Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sun, 13 Mar 2011 19:02:58 +0000 Subject: add full systemd support for new as well as migrated packages --- del-service | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'del-service') diff --git a/del-service b/del-service index c95f992..47b66a7 100755 --- a/del-service +++ b/del-service @@ -4,42 +4,60 @@ # Module : rpm-helper # File : del-service # Version : $Id$ -# Author : Frederic Lepied +# 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 [ $# != 3 ]; then - echo "usage: $0 " 1>&2 +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] [] ..." 1>&2 exit 1 fi pkg=$1 # name of the package num=$2 # number of packages installed -srv=$3 # name of the service - -systemd=no -sysv=no -options=--quiet +if [ $do_sysv = yes ]; then + srv=$3 # name of the SysV script + shift 3 +else + srv= + shift 2 +fi +units="$*" # systemd units +units_to_remove= -[ -x /bin/systemctl -a -r /lib/systemd/system/${srv}.service ] && systemd=yes -[ -r /etc/rc.d/init.d/${srv} ] && sysv=yes -[ $sysv = yes ] && options="$options --no-reload" -unit=${srv}.service if [ $num = 0 ]; then - # Will be redirected to systemd if needed + if [ -z "$DURING_INSTALL" ]; then - /sbin/service $srv stop > /dev/null || : + if [ -n "$units" ]; then + if /bin/mountpoint -q /sys/fs/cgroup/systemd; then + /bin/systemctl stop $units + fi + elif [ -n "srv" ]; then + /sbin/service $srv stop > /dev/null || : + fi fi - # support for systemd. chkconfig will do daemon-reload for us - if [ $systemd = yes ]; then - /bin/systemctl $options disable ${unit} - fi - if [ $sysv = yes ]; then - /sbin/chkconfig --del $srv + [ -n "$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" ] && \ + /bin/mountpoint -q /sys/fs/cgroup/systemd; then + /bin/rm -f /etc/rc.d/init.d/$srv + /bin/systemctl daemon-reload fi fi -- cgit v1.2.1