5af5b2
#!/bin/bash
5af5b2
#
5af5b2
# krb5kdc      Start and stop the Kerberos 5 servers.
5af5b2
#
5af5b2
# chkconfig:   - 35 65
5af5b2
# description: Kerberos 5 is a trusted third-party authentication system.  \
5af5b2
#	       This script starts and stops the server that Kerberos 5 \
5af5b2
#	       clients need to connect to in order to obtain credentials.
5af5b2
# processname: krb5kdc
5af5b2
# config: /etc/sysconfig/krb5kdc
5af5b2
# pidfile: /var/run/krb5kdc.pid
5af5b2
#
5af5b2
5af5b2
### BEGIN INIT INFO
5af5b2
# Provides: krb5kdc
5af5b2
# Required-Start: $local_fs $network
5af5b2
# Required-Stop: $local_fs $network
5af5b2
# Should-Start: portreserve
5af5b2
# Default-Start:
5af5b2
# Default-Stop: 0 1 2 3 4 5 6
5af5b2
# Short-Description: start and stop the Kerberos 5 KDC
5af5b2
# Description: The krb5kdc is the Kerberos 5 key distribution center, which \
5af5b2
#              issues credentials to Kerberos 5 clients.
5af5b2
### END INIT INFO
5af5b2
5af5b2
# Get config.
5af5b2
. /etc/sysconfig/network
5af5b2
5af5b2
# Get config.
5af5b2
[ -r /etc/sysconfig/krb5kdc ] && . /etc/sysconfig/krb5kdc
5af5b2
5af5b2
# Source function library.
5af5b2
. /etc/rc.d/init.d/functions
5af5b2
5af5b2
RETVAL=0
5af5b2
prog="Kerberos 5 KDC"
5af5b2
krb5kdc=/usr/sbin/krb5kdc
5af5b2
pidfile=/var/run/krb5kdc.pid
5af5b2
PATH=/usr/lib64/krb5:/usr/lib/krb5:"$PATH"
5af5b2
5af5b2
# Shell functions to cut down on useless shell instances.
5af5b2
start() {
5af5b2
	[ -x $krb5kdc ] || exit 5
5af5b2
	echo -n $"Starting $prog: "
5af5b2
	# tell portreserve to release the kerberos-iv port
5af5b2
	[ -x /sbin/portrelease ] && /sbin/portrelease kerberos-iv &>/dev/null || :
5af5b2
	daemon ${krb5kdc} ${KRB5REALM:+-r ${KRB5REALM}} -P $pidfile $KRB5KDC_ARGS
5af5b2
	RETVAL=$?
5af5b2
	echo
5af5b2
	if test $RETVAL -ne 0 ; then
5af5b2
	    if status ${krb5kdc} > /dev/null ; then
5af5b2
		RETVAL=0
5af5b2
	    fi
5af5b2
	fi
5af5b2
	[ $RETVAL = 0 ] && touch /var/lock/subsys/krb5kdc
5af5b2
}
5af5b2
stop() {
5af5b2
	echo -n $"Stopping $prog: "
5af5b2
	killproc ${krb5kdc}
5af5b2
	RETVAL=$?
5af5b2
	echo
5af5b2
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/krb5kdc
5af5b2
}
5af5b2
reload() {
5af5b2
	echo -n $"Reopening $prog log file: "
5af5b2
	killproc ${krb5kdc} -HUP
5af5b2
        RETVAL=$?
5af5b2
	echo
5af5b2
}
5af5b2
5af5b2
# See how we were called.
5af5b2
case "$1" in
5af5b2
  start)
5af5b2
	start
5af5b2
	;;
5af5b2
  stop)
5af5b2
	stop
5af5b2
	;;
5af5b2
  restart)
5af5b2
	stop
5af5b2
	start
5af5b2
	;;
5af5b2
  reload)
5af5b2
        reload
5af5b2
        ;;
5af5b2
  status)
5af5b2
	status ${krb5kdc}
5af5b2
        RETVAL=$?
5af5b2
	;;
5af5b2
  condrestart)
5af5b2
	if [ -f /var/lock/subsys/krb5kdc ] ; then
5af5b2
		stop
5af5b2
		start
5af5b2
	fi
5af5b2
	;;
5af5b2
  *)
5af5b2
	echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
5af5b2
	RETVAL=2
5af5b2
	;;
5af5b2
esac
5af5b2
5af5b2
exit $RETVAL