#!/bin/sh
# Author: Sven Uebelacker, 2009-2012
#
# /etc/init.d/radsecproxy
#
#   and symbolic its link
#
# /usr/bin/rcradsecproxy
#
### BEGIN INIT INFO
# Provides:          radsecproxy
# Required-Start:    $network $syslog $remote_fs radiusd
# Required-Stop:     $network $syslog $remote_fs radiusd
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: RadSecProxy-Server
# Description:       Remote Authentication Proxy for eduroam Users
### END INIT INFO

RADSECPROXY_BIN="/usr/sbin/radsecproxy"
RADSECPROXY_CONF="/etc/radsecproxy.conf"
test -x $RADSECPROXY_BIN || { echo "$RADSECPROXY_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 radsecproxy daemon "
	startproc $RADSECPROXY_BIN -c "${RADSECPROXY_CONF}" >/dev/null
	rc_status -v	
	;;
    stop)
	echo -n "Shutting down radsecproxy daemon "
	killproc -TERM $RADSECPROXY_BIN 
	rc_status -v	
	;;
    try-restart|condrestart)
	$0 status >/dev/null && $0 restart
	rc_status
	;;
    restart|reload)
	$0 stop
	$0 start
	rc_status
	;;
    status)
	echo -n "Checking for service radsecproxy"
	checkproc $RADSECPROXY_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|reload}"
	exit 1
	;;
esac
rc_exit
