aboutsummaryrefslogtreecommitdiffstats
path: root/add-service
blob: ee29e9e42d63afb332f533b00582da4f40e14534 (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
65
66
67
68
#!/bin/sh
#---------------------------------------------------------------
# Project         : Mandrake Linux
# Module          : rpm-helper
# File            : add-service
# Version         : $Id$
# Author          : Frederic Lepied
# Created On      : Mon Jul  8 08:14:34 2002
# Purpose         : helper script for rpm scriptlets to add a
#		    service.
#---------------------------------------------------------------

if [ $# != 3 ]; then
    echo "usage: $0 <pkg name> <number installed> <service name>" 1>&2
    exit 1
fi

pkg=$1				# name of the package
num=$2				# number of packages installed
srv=$3				# name of the service

if [ $num = 1 ]; then
    # Install mode: add the services
    if [ -r /etc/sysconfig/msec ]; then
	. /etc/sysconfig/msec
    fi
    if [ -n "$SECURE_LEVEL" -a "$SECURE_LEVEL" -gt 3 ]; then
	# High security: add only authorized services
	LIST=/etc/security/msec/server
	# during the install the symlink isn't done so find the right file
	# by ourseleves
	if [ -n "$DURING_INSTALL" -a ! -f $LIST ]; then
	    LIST=/etc/security/msec/server.$SECURE_LEVEL
	fi
	if [ -f $LIST ]; then
	    if grep -q "^${srv}$" $LIST ; then
		/sbin/chkconfig --add $srv
	    fi
	else
	    # do an exception for initscripts services that could be installed
	    # before msec and should anyway be added
	    if [ $pkg = initscripts ]; then
		/sbin/chkconfig --add $srv
	    else
		echo "add-service: $srv not added because /etc/security/msec/server is not present." 1>&2
		echo "You should run msec to correct that." 1>&2
	    fi
	fi
    else
	# Low security: install all the services
	/sbin/chkconfig --add $srv
    fi
else
    # Upgrade mode: restart the service if already running
    if [ -f /var/lock/subsys/$srv ]; then
	/sbin/service $srv restart > /dev/null 2>/dev/null || :
	# restart services that depend of portmap
	if [ $srv = portmap ]; then
	    for s in amd autofs bootparamd clusternfs mcserv nfs nfslock ypserv ypbind yppasswdd ypxfrd; do
		if [ -f /var/lock/subsys/$s ]; then
		    /sbin/service $s restart > /dev/null 2>/dev/null || :
		fi
	    done
	fi
    fi
fi

# add-service ends here