#!/bin/sh
. /etc/init.d/meru-functions

/etc/init.d/wncagent stop

let "i=0"
while [ "`pgrep -f /opt/meru/bin/wncagent`" ]; 
    do
	sleep 1
	let "i=$i+1"
	# when it sits for 30 secs failing to clean the agent - reboot
	if [ $i -eq 30 ]; then
	    /sbin/reboot
	fi	
    done
# the following line is for monitoring purposes only
echo $i > /tmp/secs

# Kill some wncagent mstart/mstop hanging around
if [ "`pgrep wncagent`" ]; then
	kill -9 `pgrep wncagent`
fi
	  		
pull_db
/etc/init.d/wncagent start

sleep 2
