| 1 |
tdb |
1.1 |
#!/bin/sh |
| 2 |
|
|
# |
| 3 |
|
|
# Script to check that ihost is still running, and restart if necessary. |
| 4 |
|
|
# |
| 5 |
|
|
# You probably want to add this to a cronjob, say every 10 minutes: |
| 6 |
|
|
# 0,10,20,30,40,50 * * * * /path/to/ihostchk.sh |
| 7 |
|
|
# And if you find yourself getting e-mails, use the following instead: |
| 8 |
|
|
# 0,10,20,30,40,50 * * * * /path/to/ihostchk.sh >/dev/null 2>&1 |
| 9 |
|
|
# NOTE: e-mails should only be sent if an error occurs, so the former is |
| 10 |
|
|
# the best choice for a cronjob. |
| 11 |
|
|
# |
| 12 |
tdb |
1.2 |
# $Id: ihostchk.sh,v 1.1 2001/03/12 23:23:04 tdb1 Exp $ |
| 13 |
tdb |
1.1 |
# |
| 14 |
|
|
|
| 15 |
|
|
# CHANGE this to the directory of the ihost.pl script |
| 16 |
|
|
ihostdir="/home/cut/tdb1/cvs/source/host/ihost" |
| 17 |
|
|
|
| 18 |
|
|
# CHANGE these to represent your filtermanager details |
| 19 |
|
|
fmhost="raptor.ukc.ac.uk" |
| 20 |
|
|
fmport="4567" |
| 21 |
|
|
|
| 22 |
tdb |
1.2 |
# CHANGE this to point to the PID file |
| 23 |
|
|
pidfile="/var/tmp/ihost.pid" |
| 24 |
tdb |
1.1 |
|
| 25 |
|
|
###### You probably don't need to change anything below here ###### |
| 26 |
|
|
|
| 27 |
|
|
ihost="ihost.pl" |
| 28 |
|
|
|
| 29 |
|
|
cd $ihostdir |
| 30 |
|
|
|
| 31 |
|
|
# is there a pid file? |
| 32 |
|
|
if test -r $pidfile |
| 33 |
|
|
then |
| 34 |
|
|
# there is a pid file, check to see if it's current |
| 35 |
|
|
ihostpid=`cat $pidfile` |
| 36 |
|
|
if `kill -CHLD $ihostpid >/dev/null 2>&1` |
| 37 |
|
|
then |
| 38 |
|
|
# it's still alive, lets leave it be |
| 39 |
|
|
exit 0 |
| 40 |
|
|
fi |
| 41 |
|
|
# old pid file found |
| 42 |
|
|
echo "" |
| 43 |
|
|
echo "Stale $pidfile file, removing..." |
| 44 |
|
|
rm -f $pidfile |
| 45 |
|
|
fi |
| 46 |
|
|
|
| 47 |
|
|
# if we got here, we're clear to restart ihost |
| 48 |
|
|
echo "" |
| 49 |
|
|
echo "ihost is not running, starting up..." |
| 50 |
|
|
echo "" |
| 51 |
|
|
./$ihost $fmhost $fmport & |
| 52 |
|
|
exit 0 |
| 53 |
|
|
|
| 54 |
|
|
# finished |