#! /bin/sh
# Copyright (c) 1995-2002 SuSE LINUX Products GmbH, Nuernberg, Germany.
# All rights reserved.
#
# Author: Michael Calmer <Michael.Calmer@suse.de>
#
# /etc/init.d/krb524d
#
### BEGIN INIT INFO
# Provides:          krb524d
# Required-Start:    $syslog $remote_fs
# Should-Start: $time
# Required-Stop:     $syslog $remote_fs
# Should-Stop: $time
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start and stop the krb524 service.
# Description:       Kerberos 5 is a trusted third-party authentication system.
#              This script starts and stops krb524d, which converts
#              Kerberos 5 credentials to Kerberos IV credentials.
### END INIT INFO
#
# krb524       Start and stop the krb524 service.
#
# chkconfig:   - 35 65
# description: Kerberos 5 is a trusted third-party authentication system.  \
#              This script starts and stops krb524d, which converts \
#              Kerberos 5 credentials to Kerberos IV credentials.
# processname: krb524d
#

RETVAL=0
prog="Kerberos 5-to-4 Server"
krb524d=/usr/lib/mit/sbin/krb524d
krbdir=/var/lib/kerberos/krb5kdc

. /etc/rc.status

# Reset status of this service
rc_reset


# Shell functions to cut down on useless shell instances.
start() {
  	if [ ! -f $krbdir/principal ] ; then
	    echo "No principal database found, exiting."
	    echo
	    exit 0
	fi
	echo -n "Starting $prog"
	startproc ${krb524d} -m

        # Remember status and be verbose
        rc_status -v

}
stop() {
	echo -n  "Shutting down $prog"
	killproc -TERM ${krb524d}

        # Remember status and be verbose
        rc_status -v

}
reload() {
	echo -n "Reload service $prog"
	killproc ${krb524d} -HUP

        rc_status -v
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  try-restart)
        $0 status
        if test $? = 0; then
                $0 restart
        else
                rc_reset        # Not running is not a failure.
        fi
        # Remember status and be quiet
        rc_status
        ;;

  restart)
	$0 stop
	$0 start

        # Remember status and be quiet
        rc_status
	;;
  reload|force-reload)
        reload
        ;;
  status)
        echo -n "Checking for service $prog"
	checkproc ${krb524d}
        rc_status -v
	;;
  *)
	echo "Usage: $0 {start|stop|status|reload|force-reload|restart|try-restart}"
        exit 1
	;;
esac
rc_exit
