#!/bin/sh

# Crontab script for Anope
#
# Check to see if Anope is runinng, if not it will start it.
#
# Note: This script doesn't rely on a pid-file, and therefore it
# isn't sensitive if services is running on a machine with
# heavy I/O load.
#
# Example crontab entry:
# */5 * * * * /path/to/services.chk >/dev/null 2>&1

###############################################################
# CONFIGURATION
###############################################################

# Anope binary directory
ANOPATH=/path/to/services/bin

# Name of the executable
ANOPROG=services

# Parameters to pass to the executable
ANOARGS=""

###############################################################
#                 DON'T EDIT ANYTHING BELOW                   #
###############################################################

PATH=/bin:/usr/bin:/usr/local/bin

cd $ANOPATH

PROCESS=`ps uwx | grep $ANOPROG | grep -v grep | awk '{print $11}'`

if [ -z "$PROCESS" ]; then
        echo "Not running, starting $ANOPROG"
        ./$ANOPROG $ANOARGS
        exit
else
        echo "$ANOPROG running"
        exit
fi