--- scripts/radwatch.orig	Sat Jun  9 02:02:03 2001
+++ scripts/radwatch	Thu Jul  5 16:00:31 2001
@@ -8,9 +8,9 @@
 #
 
 RWLOG="/var/log/radwatch.log"		# Use "/dev/null" for no logging
-RWCMD="/usr/local/sbin/radiusd -y"	# Path to radiusd + run-time arguments
-RWRCP="foo@bar.com"			# Recipient for alerts.  Comment out to disable
-RWINT=10				# Time in seconds between process list polls
+RWCMD="%%PREFIX%%/sbin/radiusd"		# Path to radiusd + run-time arguments
+#RWRCP="foo@bar.com"			# Recipient for alerts.  Comment out to disable
+RWINT=8 				# Time in seconds between process list polls
 
 UNAME=`uname`
 
@@ -35,7 +35,16 @@
     ;;
 esac
 
+# get the path to the radiusd
+if [ "$1" ] && [ -x "$1" ]
+then
+        RWCMD=$1
+        shift
+fi
+
 (
+trap "" HUP TSTP
+
 while :
 do
 
@@ -54,16 +63,21 @@
   fi
 
   if [ $COUNT -lt 2 ]; then
+    sleep 3
     STAMP=`date "+%m/%d/%y %H:%M:%S"`
     ALERT="$COUNT processes.  Restarting ICRADIUS."
     echo "$STAMP	`basename $0`:  $ALERT" >> $RWLOG
     if [ "$RWRCP" != "" ]; then
       echo "`basename $0`:  $ALERT" | mail -s "ICRADIUS Restarted" $RWRCP
     fi
-    kill $PIDS 2>/dev/null; $RWCMD
+    kill $PIDS 2>/dev/null; $RWCMD $*
   fi
   
   sleep $RWINT
 
 done
 ) &
+
+echo "$!" > /var/run/radwatch.pid
+
+sleep 1
