#! /bin/sh
# Copyright (c) 2001       SuSE GmbH Nuernberg, Germany.
#               2002, 2003 SuSE Linux AG, Nuernberg, Germany.
#
# Author: Wolfgang Rosenauer, 2000-2003
#
# /etc/init.d/radiusd
#
#   and symbolic its link
#
# /usr/bin/rcradiusd
#
### BEGIN INIT INFO
# Provides:          radiusd
# Required-Start:    $network $syslog $remotefs
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: RADIUS-Server
# Description:       Remote Authentication Dialin User Server
### END INIT INFO

RADIUSD_BIN=/usr/sbin/radiusd
test -x $RADIUSD_BIN || { echo "$RADIUSD_BIN not installed"; \
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

. /etc/rc.status

rc_reset
case "$1" in
    start)
	echo -n "Starting RADIUS daemon "
	startproc $RADIUSD_BIN >/dev/null
	rc_status -v	
	;;
    stop)
	echo -n "Shutting down RADIUS daemon "
	killproc -TERM $RADIUSD_BIN 
	rc_status -v	
	;;
    try-restart|condrestart)
	## If first returns OK call the second, if first or
	## second command fails, set echo return value.
	if test "$1" = "condrestart"; then
		echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
	fi
	$0 status
	if test $? = 0; then
	        $0 restart
	else
	        rc_reset        # Not running is not a failure.
	fi
	rc_status
	;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
	$0 stop
	$0 start
	rc_status
	;;
    force-reload)
        ## Signal the daemon to reload its config. Most daemons
        ## do this on signal 1 (SIGHUP).
        ## If it does not support it, restart.

	echo -n "Reload RADIUS daemon "
        killproc -HUP $RADIUSD_BIN
        rc_status -v
	;;
    reload)
        ## Like force-reload, but if daemon does not support
        ## signalling, do nothing (!)

	echo -n "Reload RADIUS daemon "
	killproc -HUP $RADIUSD_BIN 
	rc_status -v
	;;
    status)
	echo -n "Checking for service radiusd "
	checkproc $RADIUSD_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
	exit 1
	;;
esac
rc_exit
