#!/bin/sh
# Crontab script for Anope
# Anope binary directory
ANOPATH=/home/ircd/services/daemon/
# Name of the pid file
ANOPIDF=services.pid
# Name of the executable
ANOPROG=services
PATH=/bin:/usr/bin:/usr/local/bin
ANOPID=
cd $ANOPATH
if [ -f $ANOPIDF ]
then
# If pid file is found
ANOPID=`cat $ANOPIDF`
if [ `ps auwx | grep $ANOPROG | grep $ANOPID | grep -v -c grep` = 1 ]
then
# services.pid is found and is running...
# exit silently ;-)
exit
fi
# If pid exists, but isn't found running...
echo "Anope Crontab notice:"
echo ""
echo "Stale $ANOPIDF file (erasing it)."
echo ""
# remove it
rm -f $ANOPIDF
fi
# If the pid file isn't found...start anope...
echo "Anope Crontab notice:"
echo ""
echo "Couldn't find the services running. Reloading it..."
echo ""
./$ANOPROG