benbot/bot

83 lines
1.5 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
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
2017-05-01 11:47:07 +00:00
echo "${WHICHBOT} already running"
else
2017-05-01 11:47:07 +00:00
echo "starting ${WHICHBOT} in background (nohup)"
nohup php run.php > bot.out 2> bot.err < /dev/null &
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
2017-05-01 11:47:07 +00:00
echo "killing ${WHICHBOT} ($pid)"
kill $pid
fi
;;
status)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
2017-05-01 11:47:07 +00:00
echo "${WHICHBOT} running with pid $pid"
else
2017-05-01 11:47:07 +00:00
echo "${WHICHBOT} 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-05-01 11:47:07 +00:00
less bot.out
else
2017-05-01 11:47:07 +00:00
echo "${WHICHBOT} 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)
2017-09-19 16:00:42 +00:00
rsync -av ben@tilde.team:workspace/benbot/uploaded_images/ uploaded_images/
rsync -av ben@tilde.team:workspace/benbot/bot_data/ bot_data/
2017-04-27 18:03:00 +00:00
2017-04-20 20:42:59 +00:00
;;
restart)
2017-04-13 06:16:15 +00:00
if [ $pid ]; then
2017-05-01 11:47:07 +00:00
echo "killing ${WHICHBOT} ($pid)"
kill $pid
fi
2017-05-01 11:47:07 +00:00
echo "starting ${WHICHBOT} in background (nohup)"
nohup php run.php > 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
2017-05-01 11:47:07 +00:00