#! /bin/sh

botdir="/root/software/cs-chatbot"

cd $botdir

if test -r cs-chatbot.pid
then
  botpid=`cat cs-chatbot.pid`
  if `kill -CHLD $botpid >/dev/null 2>&1`
  then
    exit 0
  fi
  echo ""
  echo "Stale cs-chatbot.pid file, erasing..."
  rm -f cs-chatbot.pid
fi

echo ""
echo "Couldn't find bot 'CS-ChatBot' running, reloading..."
echo ""
./cs-chatbot &> /dev/null &
exit 0
