#!/bin/bash
#
# Redhat System V init script for OpenRADIUS

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

OPTIONS="-o /var/log/openradius/radiusd.log -d all"
RETVAL=0
prog="OpenRADIUS"

start() {
        echo -n $"Starting $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                daemon --user radiusd /usr/local/sbin/radiusd $OPTIONS
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/radiusd
        fi;
        echo 
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                killproc /usr/local/sbin/radiusd
                RETVAL=$?
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/radiusd
        fi;
        echo
        return $RETVAL
}

reload(){
        echo -n $"Reloading $prog: "
        RETVAL=1
	failure
        echo
        return $RETVAL
}

restart(){
	stop
	start
}

condrestart(){
    [ -e /var/lock/subsys/radiusd ] && restart
    return 0
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
        ;;
  reload)
	reload
        ;;
  condrestart)
	condrestart
	;;
  status)
        status radiusd
	RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
	RETVAL=1
esac

exit $RETVAL


syntax highlighted by Code2HTML, v. 0.9.1