Pull fix from branch_1_1, so proxied EAP replies work
[freeradius.git] / scripts / radwatch.in
1 #! /bin/sh
2 #
3 # radwatch      Script to watch RADIUS. Sends mail to root and
4 #               restarts radiusd when it dies [which ofcourse
5 #               never happens :)]
6 #
7 #   WARNING!  This script SHOULD NOT BE USED!  It's only here for historical
8 #             purposes, and WILL be deleted in a future version of the
9 #             the server.
10 #
11 #             If you want to watch and re-start the server, we recommend
12 #             reading the file doc/supervise-radiusd.txt
13 #
14 #
15 # Version:      $Id$
16 #
17
18 prefix=@prefix@
19 exec_prefix=@exec_prefix@
20 sbindir=@sbindir@
21 localstatedir=@localstatedir@
22 logdir=@logdir@
23 rundir=${localstatedir}/run/radiusd
24
25 MAILTO=root
26 RADIUSD=$sbindir/radiusd
27
28 exec >> $logdir/radwatch.log 2>&1
29
30 # get the path to the radiusd
31 if [ "$1" ] && [ -x "$1" ]
32 then
33         RADIUSD=$1
34         shift
35 fi
36
37 cd $logdir
38 [ -d $logdir/radacct ] && cd $logdir/radacct
39 ulimit -c unlimited
40
41 (
42         trap 'echo `date`: exit; kill `cat $rundir/radiusd.pid`; exit 0' TERM
43         trap "" HUP TSTP
44
45         while :
46         do
47                 # Use `wait', otherwise the trap doesn't work.
48                 $RADIUSD -f $* &
49                 echo "$!" > $rundir/radiusd.pid
50                 wait
51                 exec >> $logdir/radwatch.log 2>&1
52                 echo "`date`: Radius died, restarting.."
53                 date | mail -s "Radius died, restarting.." $MAILTO
54                 sleep 10
55         done
56 ) &
57
58 echo "$!" > $rundir/radwatch.pid
59
60 sleep 1