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

RADIUSD_BIN=/usr/sbin/radrelay
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 Relay daemon "
	startproc $RADIUSD_BIN -s -n radrelay >/dev/null
	rc_status -v	
	;;
    stop)
	echo -n "Shutting down RADIUS Relay 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 Relay 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 Relay daemon "
	killproc -HUP $RADIUSD_BIN 
	rc_status -v
	;;
    status)
	echo -n "Checking for service radius-relayd "
	checkproc $RADIUSD_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
	exit 1
	;;
esac
rc_exit
