summaryrefslogtreecommitdiffstats
path: root/kadmind.init
blob: 65685593a803ae112696d3a8e88a93dd5f2f871d (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#
# kadmind      Start and stop the Kerberos 5 administrative server.
#
# chkconfig:   - 35 65
# description: Kerberos 5 is a trusted third-party authentication system.  \
#	       This script starts and stops the Kerberos 5 administrative \
#              server, which should only be run on the master server for a \
#              realm.
# processname: kadmind
# config: /etc/sysconfig/kadmin
# pidfile: /var/run/kadmind.pid
#

### BEGIN INIT INFO
# Provides: kadmin
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: portreserve
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: start and stop the Kerberos 5 admin server
# Description: The kadmind service allows administrators to remotely manage \
#              the Kerberos 5 realm database.  It should only be run on a \
#              master KDC.
### END INIT INFO

# Get config.
. /etc/sysconfig/network

# Get config.
[ -r /etc/sysconfig/kadmin ] && . /etc/sysconfig/kadmin

# Source function library.
. /etc/init.d/functions
prog="Kerberos 5 Admin Server"
kadmind=/usr/sbin/kadmind
pidfile=/var/run/kadmind.pid

RETVAL=0

# Shell functions to cut down on useless shell instances.
start() {
  	if [ ! -f /var/kerberos/krb5kdc/principal ] ; then
	    # Make an educated guess -- if they're using kldap somewhere,
	    # then we don't know for sure that this is an error.
  	    if ! grep -q 'db_library.*=.*kldap' /etc/krb5.conf ; then
	        echo $"Error. Default principal database does not exist."
	        exit 1
	    fi
	fi
  	if [ -f /var/kerberos/krb5kdc/kpropd.acl ] ; then
	    echo $"Error. This appears to be a slave server, found kpropd.acl"
	    exit 6
	else
	    [ -x $kadmind ] || exit 5
	fi
	echo -n $"Starting $prog: "
	# tell portreserve to release the kerberos-adm port
	[ -x /sbin/portrelease ] && /sbin/portrelease kerberos-adm &>/dev/null || :
	daemon ${kadmind} ${KRB5REALM:+-r ${KRB5REALM}} -P $pidfile $KADMIND_ARGS
	RETVAL=$?
	echo
	if test $RETVAL -ne 0 ; then
	    if status -l kadmin ${kadmind} > /dev/null ; then
		RETVAL=0
	    fi
	fi
	[ $RETVAL = 0 ] && touch /var/lock/subsys/kadmin
}
stop() {
	echo -n $"Stopping $prog: "
	killproc ${kadmind}
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/kadmin
}
reload() {
	echo -n $"Reopening $prog log file: "
	killproc ${kadmind} -HUP
	RETVAL=$?
	echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  status)
	status -l kadmin ${kadmind}
	RETVAL=$?
	;;
  reload)
	reload
	;;
  condrestart)
	if [ -f /var/lock/subsys/kadmin ] ; then
		stop
		start
	fi
	;;
  *)
	echo $"Usage: $0 {start|stop|status|condrestart|reload|restart}"
	RETVAL=2
	;;
esac

exit $RETVAL