#! /bin/sh # # radwatch Script to watch RADIUS. Sends mail to root and # restarts radiusd when it dies [which ofcourse # never happens :)] # # Version: @(#)radwatch 1.10 28-Nov-1998 miquels@cistron.nl # MAILTO=root RADIUSD=/usr/local/sbin/radiusd exec >> /var/log/radwatch.log 2>&1 # get the path to the radiusd if [ "$1" ] && [ -x "$1" ] then RADIUSD=$1 shift fi cd /var/log [ -d /var/log/radacct ] && cd /var/log/radacct ulimit -c unlimited ( trap 'echo `date`: exit; kill `cat /var/run/radiusd.pid`; exit 0' TERM trap "" HUP TSTP while : do # Use `wait', otherwise the trap doesn't work. $RADIUSD -f $* & wait exec >> /var/log/radwatch.log 2>&1 echo "`date`: Radius died, restarting.." date | mail -s "Radius died, restarting.." $MAILTO sleep 10 done ) & echo "$!" > /var/run/radwatch.pid sleep 1