Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 18e9e957d3690555fc6e7a51085fc8b1 > files > 36

krb5-1.6.3-6mdv2009.0.src.rpm

#!/bin/bash
#
# krb5kdc      Start and stop the Kerberos 5 servers.
#
# chkconfig: 345 35 65
# description: Kerberos 5 is a trusted third-party authentication system.  \
#	       This script starts and stops the server that Kerberos IV and 5 \
#	       clients need to connect to in order to obtain credentials.
# processname: krb5kdc
#
### BEGIN INIT INFO
# Provides: krb5kdc
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: Kerberos 5 KDC
# Description: This is the Kerberos 5 Key Distribution Center server, \
#              which is used by clients to obtain credentials.
### END INIT INFO

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0
prog="Kerberos 5 KDC"
krb5kdc=/usr/sbin/krb5kdc

exist_database() {
    if grep -qE \
        "^[[:blank:]]*db_library[[:blank:]]*=[[:blank:]]*kldap$" \
        /etc/krb5.conf; then
            return 0
    fi
    if [ ! -f /etc/kerberos/krb5kdc/principal ] ; then
        return 1
    else
        return 0
    fi
}

# Sheel functions to cut down on useless shell instances.
start() {
	if ! exist_database; then
        gprintf "Warning, no kerberos database initialized, exiting.\n"
        return 1
    fi
	echo -n $"Starting $prog: "
	daemon ${krb5kdc}
	
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/krb5kdc
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc ${krb5kdc}
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/krb5kdc
	return $RETVAL
}

reload() {
       echo -n $"Reopening $prog log file: "
       killproc ${krb5kdc} -HUP
       RETVAL=$?
       echo
	   return $RETVAL
}

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

exit $RETVAL