#! /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/kpropd
#
### BEGIN INIT INFO
# Provides:          kprop
# Required-Start:    $syslog $remote_fs $network
# Should-Start: $time
# Required-Stop:     $syslog $remote_fs $network
# Should-Stop: $time
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start and stop the Kerberos 5 propagation client.
# Description:       Kerberos 5 is a trusted third-party authentication system.  \
#              This script starts and stops the service that allows this \
#              KDC to receive updates from your master KDC.
### END INIT INFO

#
# kpropd.init  Start and stop the Kerberos 5 propagation client.
#
# chkconfig:   35 35 65
# description: Kerberos 5 is a trusted third-party authentication system.  \
#	       This script starts and stops the service that allows this \
#              KDC to receive updates from your master KDC.
# processname: kpropd
#

prog="Kerberos 5 Propagation Server"
kpropd=/usr/lib/mit/sbin/kpropd
krbdir=/var/lib/kerberos/krb5kdc

. /etc/rc.status

# Reset status of this service
rc_reset

# Sheel functions to cut down on useless shell instances.
start() {
 	if ! grep -q ^krb5_prop /etc/services ; then
	    echo "krb5_prop not in /etc/services. Please add 'krb5_prop      754/tcp' to /etc/services ."
	    rc_failed 1
	    rc_status -v
	    rc_exit
	fi
	if ! grep -q ^eklogin /etc/services ; then
            echo "eklogin not in /etc/services."
	    echo "Please add 'eklogin          2105/tcp' to /etc/services and enable this service in /etc/xinetd.d/eklogin."
            rc_failed 1
	    rc_status -v
	    rc_exit
        fi

 	if [ ! -f $krbdir/kpropd.acl ] ; then
	    echo "Could not find an ACL file for the propagation server, exiting."
	    rc_failed 1
	    rc_status -v
	    rc_exit
	fi

	echo -n "Starting $prog"
	startproc ${kpropd} -S

        # Remember status and be verbose
        rc_status -v
        
}
stop() {
	echo -n "Stopping $prog"
	killproc ${kpropd}

        # Remember status and be verbose
        rc_status -v

}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	$0 stop
	$0 start
	;;
  status)
        echo -n "Checking for service $prog"
	checkproc ${kpropd}
	rc_status -v
	;;
  try-restart|force-reload)
        $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

	;;
  reload)
        echo -n "Reload service $prog"
        rc_failed 3
        rc_status -v
        ;;
  *)
	echo "Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
        exit 1
	;;
esac
rc_exit
