benbot/bot

84 lines
1.6 KiB
Plaintext
Raw Normal View History

2017-03-13 23:31:15 +00:00
#!/bin/bash
2017-05-01 04:00:06 +00:00
source .env
2017-04-13 06:16:15 +00:00
# pid=$(ps -ef | grep BenBot | grep -v grep | awk '{print $2}')
2017-05-01 04:00:06 +00:00
pid=$(pidof $WHICHBOT)
2017-03-13 23:31:15 +00:00
case "$1" in
nohup)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
echo "starting BenBot in background (nohup)"
2017-05-01 04:00:06 +00:00
nohup php run.php $WHICHBOT > bot.out 2> bot.err < /dev/null &
else
echo "BenBot already running"
fi
;;
start)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
kill $pid
fi
php run.php
;;
stop)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
echo "killing BenBot ($pid)"
kill $pid
fi
;;
status)
2017-04-13 06:16:15 +00:00
#pgrep BenBot && echo "Running"
if [ $pid ]; then
echo "BenBot running with pid $pid"
else
echo "BenBot not running"
fi
;;
2017-03-14 13:47:03 +00:00
2017-03-16 07:01:59 +00:00
log)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
2017-03-16 07:01:59 +00:00
less bot.out
else
echo "BenBot not running"
2017-03-16 07:01:59 +00:00
fi
;;
check)
find ./src -name \*.php -exec php -l "{}" \;
php -l *.php
;;
2017-04-20 20:42:59 +00:00
loc)
2017-04-27 18:03:00 +00:00
find src -name '*.php' | xargs wc -l
2017-04-20 20:42:59 +00:00
;;
cloc)
2017-05-01 04:00:06 +00:00
cloc --exclude-dir=vendor --by-file-by-lang .
2017-04-27 18:03:00 +00:00
;;
sync)
rsync -av ben@benharris.ch:workspace/benbot/uploaded_images/ uploaded_images/
rsync -av ben@benharris.ch:workspace/benbot/bot_data/ bot_data/
2017-04-20 20:42:59 +00:00
;;
restart)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
echo "killing BenBot ($pid)"
kill $pid
fi
echo "starting BenBot in background (nohup)"
2017-05-01 04:00:06 +00:00
nohup php run.php $WHICHBOT > bot.out 2> bot.err < /dev/null &
;;
2017-03-13 23:31:15 +00:00
2017-03-14 13:47:03 +00:00
*)
echo $"Usage: $0 {start|nohup|stop|restart|log|status}"
exit 1
2017-03-13 23:31:15 +00:00
esac