#!/bin/sh
#
# radiusd	Free RADIUS Daemon
#
# chkconfig: - 88 10
# description:	Start/Stop the RADIUS server daemon
#
#
# processname: radiusd
# config: /etc/raddb/radiusd.conf
# pidfile: /var/run/radiusd/radiusd.pid
# Required-Start: $network
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

PIDFILE=/var/run/radiusd/radiusd.pid
LOCKFILE=/var/lock/subsys/radiusd
RETVAL=0

start()
{
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user radiusd -- radiusd
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user radiusd -- radiusd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	msg_reloading radiusd
	stop_daemon --pidfile "$PIDFILE" --expect-user radiusd -HUP -- radiusd
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user radiusd -- radiusd
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
