#!/bin/sh
#
# To check for your every 10 minutes, put the following line in your
# crontab:
#    0,10,20,30,40,50 * * * *   /home/mydir/chkircd
# And if you don't want to get email from crontab when it checks,
# put the following in your crontab:
#    0,10,20,30,40,50 * * * *   /home/mydir/chkircd >/dev/null 2>&1
#
# change this to the directory you run your ircd from:
ircddir="/home/bosco/local/ircd"
cd $ircddir
if test -r ircd.pid; then
  # there is a pid file -- is it current?
  ircdpid=`cat ircd.pid`
  if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
    # it's still going
# echo "Found the ircd running."
    # back out quietly
    exit 0
  fi
  echo ""
  echo "Stale ircd.pid file (erasing it)" 
  rm -f ircd.pid
fi
echo ""
echo "Couldn't find the ircd running.  Reloading it..."
echo ""
# Check for conffile first
if test -r ircd.conf; then
   # It's there, load the ircd
  ./ircd
  exit 0
fi

# Well, nothing to work with...
echo "Nope.  Could not reload the ircd.."
exit 0
