aboutsummaryrefslogtreecommitdiffstats
path: root/del-service
blob: 47b66a73805b4eb81a8c41c82c1c893344237357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/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

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
units_to_remove=


if [ $num = 0 ]; then

    if [ -z "$DURING_INSTALL" ]; then
	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

    [ -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

# del-service ends here