benbot/bot

68 lines
1.3 KiB
Bash

#!/bin/bash
# pid=$(ps -ef | grep BenBot | grep -v grep | awk '{print $2}')
pid=$(pidof BenBot)
case "$1" in
nohup)
if [ $pid ]; then
echo "starting BenBot in background (nohup)"
nohup php run.php > bot.out 2> bot.err < /dev/null &
else
echo "BenBot already running"
fi
;;
start)
if [ $pid ]; then
kill $pid
fi
php run.php
;;
stop)
if [ $pid ]; then
echo "killing BenBot ($pid)"
kill $pid
fi
;;
status)
#pgrep BenBot && echo "Running"
if [ $pid ]; then
echo "BenBot running with pid $pid"
else
echo "BenBot not running"
fi
;;
log)
if [ $pid ]; then
less bot.out
else
echo "BenBot not running"
fi
;;
check)
find ./src -name \*.php -exec php -l "{}" \;
php -l *.php
;;
restart)
if [ $pid ]; then
echo "killing BenBot ($pid)"
kill $pid
fi
echo "starting BenBot in background (nohup)"
nohup php run.php > bot.out 2> bot.err < /dev/null &
;;
*)
echo $"Usage: $0 {start|nohup|stop|restart|log|status}"
exit 1
esac