#!/bin/sh
#
# PTlink IRCD Crontab 
#
# This is a script suitable for use in a crontab.  It checks to make sure
# your ircd is running.  YOU NEED A SEPARATE CRON JOB FOR EACH IRCD.  If your
# ircd isn't found, it'll try to start it back up.
#
# Modified by Duck for packaging purpose
#

# I wouldn't touch this if I were you.
ircdname="/var/run/ircd-ptlink/ircd.pid"

########## you probably don't need to change anything below here ##########

if test -r $ircdname; then
  # there is a pid file -- is it current?
  ircdpid=`cat $ircdname`
  if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
    # it's still going
    # back out quietly
    exit 0
  fi
  echo ""
  echo "Stale $ircdname file (erasing it)"
  rm -f $ircdname
fi
echo ""
echo "Couldn't find the ircd running.  Reloading it..."
echo ""
/etc/init.d/ircd-ptlink start

