cvsdist 0bb98ee
#!/bin/bash
cvsdist af3b546
#
cvsdist af3b546
# kadmind      Start and stop the Kerberos 5 administrative server.
cvsdist af3b546
#
cvsdist af3b546
# chkconfig:   - 35 65
cvsdist af3b546
# description: Kerberos 5 is a trusted third-party authentication system.  \
cvsdist af3b546
#	       This script starts and stops the Kerberos 5 administrative \
cvsdist af3b546
#              server, which should only be run on the master server for a \
cvsdist af3b546
#              realm.
cvsdist af3b546
# processname: kadmind
c22df5b
# config: /etc/sysconfig/kadmin
cvsdist af3b546
#
cvsdist af3b546
cvsdist af3b546
# Get config.
cvsdist af3b546
. /etc/sysconfig/network
cvsdist af3b546
cvsdist af3b546
# Check that networking is up.
cvsdist af3b546
[ ${NETWORKING} = "no" ] && exit 0
cvsdist af3b546
708fedd
# Get config.
708fedd
[ -r /etc/sysconfig/kadmin ] && . /etc/sysconfig/kadmin
708fedd
cvsdist af3b546
# Source function library.
cvsdist af3b546
. /etc/init.d/functions
cvsdist 21f3145
prog="Kerberos 5 Admin Server"
cvsdist 21f3145
kadmind=/usr/kerberos/sbin/kadmind
cvsdist af3b546
cvsdist af3b546
RETVAL=0
cvsdist af3b546
cvsdist 21f3145
# Shell functions to cut down on useless shell instances.
cvsdist af3b546
start() {
cvsdist af3b546
  	if [ ! -f /var/kerberos/krb5kdc/principal ] ; then
a9c20b1
	    # Make an educated guess -- if they're using kldap somewhere,
a9c20b1
	    # then we don't know for sure that this is an error.
12649ed
  	    if ! grep -q 'db_library.*=.*kldap' /etc/krb5.conf ; then
a9c20b1
	        echo $"Error. Default principal database does not exist."
de59fb0
	        exit 0
a9c20b1
	    fi
cvsdist af3b546
	fi
cvsdist af3b546
  	if [ -f /var/kerberos/krb5kdc/kpropd.acl ] ; then
54faf41
	    echo $"Error. This appears to be a slave server, found kpropd.acl"
cvsdist af3b546
	    exit 0
cvsdist af3b546
	else
cvsdist af3b546
  	    if [ ! -f /var/kerberos/krb5kdc/kadm5.keytab ] ; then
cvsdist 0bb98ee
		echo -n $"Extracting kadm5 Service Keys: "
a9c20b1
		# This should always work.
2e8f6b3
		/usr/kerberos/sbin/kadmin.local ${KRB5REALM:+-r $KRB5REALM} -q "ktadd -k /var/kerberos/krb5kdc/kadm5.keytab kadmin/admin${KRB5REALM:+@$KRB5REALM} kadmin/changepw${KRB5REALM:+@$KRB5REALM}" && success || failure
a9c20b1
		# It's probably okay if this fails.
a9c20b1
		/usr/kerberos/sbin/kadmin.local ${KRB5REALM:+-r $KRB5REALM} -q "ktadd -k /var/kerberos/krb5kdc/kadm5.keytab kadmin/`hostname`${KRB5REALM:+@$KRB5REALM}" 2> /dev/null && success
cvsdist af3b546
		echo
cvsdist af3b546
	    fi
cvsdist af3b546
	fi
cvsdist 21f3145
	echo -n $"Starting $prog: "
2e8f6b3
	daemon ${kadmind} ${KRB5REALM:+-r ${KRB5REALM}} $KADMIND_ARGS
cvsdist af3b546
	RETVAL=$?
cvsdist af3b546
	echo
cvsdist af3b546
	[ $RETVAL = 0 ] && touch /var/lock/subsys/kadmin
cvsdist af3b546
}
cvsdist af3b546
stop() {
cvsdist 21f3145
	echo -n $"Stopping $prog: "
cvsdist 21f3145
	killproc ${kadmind}
cvsdist af3b546
	RETVAL=$?
cvsdist af3b546
	echo
cvsdist af3b546
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/kadmin
cvsdist af3b546
}
cvsdist 21f3145
reload() {
cvsdist 21f3145
	echo -n $"Reopening $prog log file: "
cvsdist 21f3145
	killproc ${kadmind} -HUP
cvsdist 21f3145
	RETVAL=$?
cvsdist 21f3145
	echo
cvsdist 21f3145
}
cvsdist af3b546
cvsdist af3b546
# See how we were called.
cvsdist af3b546
case "$1" in
cvsdist af3b546
  start)
cvsdist af3b546
	start
cvsdist af3b546
	;;
cvsdist af3b546
  stop)
cvsdist af3b546
	stop
cvsdist af3b546
	;;
cvsdist af3b546
  restart)
cvsdist af3b546
	stop
cvsdist af3b546
	start
cvsdist af3b546
	;;
cvsdist af3b546
  status)
cvsdist 21f3145
	status ${kadmind}
cvsdist 21f3145
	RETVAL=$?
cvsdist 21f3145
	;;
cvsdist 21f3145
  reload)
cvsdist 21f3145
	reload
cvsdist af3b546
	;;
cvsdist af3b546
  condrestart)
cvsdist af3b546
	if [ -f /var/lock/subsys/kadmin ] ; then
cvsdist af3b546
		stop
cvsdist af3b546
		start
cvsdist af3b546
	fi
cvsdist af3b546
	;;
cvsdist af3b546
  *)
cvsdist 21f3145
	echo $"Usage: $0 {start|stop|status|condrestart|reload|restart}"
cvsdist af3b546
	RETVAL=1
cvsdist af3b546
	;;
cvsdist af3b546
esac
cvsdist af3b546
cvsdist af3b546
exit $RETVAL