#! /bin/sh
#! This is the watchdog script for the empire processes.
#! Written with the help of a few of the old empire hackers from
#! pieces of scripts found lying under some empty coke cans and pizza 
#! crusts.
#! This particualar version runs on Sun and Ultrix systems.  HP systems
#! need to have the 'ps' command altered.
#!
#!  The cron entry to have this script check for processes is as follows. 
#!  0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/evil/scripts/watchdog
#! 
#! Dave 'TheEvilOne' Nye, evil@bbn.com

filename=/tmp/empcheck`whoami`
EMPIREDIR=/home/evil/EMP/

ps -aux > $filename

if grep emp_tm $filename >> /dev/null;then
echo 'everything is fine'>> /dev/null
else
	rm -f $EMPIREDIR/data/tm_port
	cd /home/evil/EMP/bin/;emp_tm
	echo emp_tm was gone.  tm_port removed and tm restarted.
fi

if grep emp_login $filename >> /dev/null;then
echo 'everything is fine'>> /dev/null
else
	cd /home/evil/EMP/bin/;emp_login
	echo emp_login was gone.  Restarted.
fi

