#!/bin/sh

# This script launches dancer unless it's already running.
# You can put it in a crontab. This checks each half hour
# 0,30 * * * * /home/breese/dancer/launch.sh

# In order to make your bot run from a special IP number of your multiple IP
# host, make the DANCER_MYHOST below contain the *IP* address of your choice.

#DANCER_MYHOST=host.domain
#export DANCER_MYHOST

# The dancer directory
path="/home/breese/dancer"
# The name of the executable
prog="dancer"
# The PID file
pidfile="$path/.pid"
# The logfile for this script
logfile="/dev/null"

if [ -f $pidfile ]; then
    pid=`cat $pidfile`
    kill -0 $pid > $logfile 2>&1 || (cd $path;$prog > $logfile 2>&1 &)
else
    (cd $path;$prog > $logfile 2>&1 &)
fi
