telegram-bot-bash/bashbot.rc

87 lines
2.0 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# description: Start or stop telegram-bash-bot
#
2019-05-26 14:50:19 +00:00
#### $$VERSION$$ v0.90-dev2-0-gec85636
2019-04-01 16:24:05 +00:00
# shellcheck disable=SC2009
# shellcheck disable=SC2181
#
### BEGIN INIT INFO
# Provides: bashbot
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start or stop telegram-bot-bash server
### END INIT INFO
2019-04-04 10:45:31 +00:00
# save default values
TERM="" # disable bashbot clear and color output
runas="nobody"
2019-04-01 10:52:25 +00:00
runcmd="echo Dry run:" # not actived until you edit lines below
2019-04-04 10:45:31 +00:00
#######################
# Configuration Section
2019-04-04 10:45:31 +00:00
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
# runas="nobody"
2019-04-04 10:45:31 +00:00
# uncomment one of the following lines to fit your system
# runcmd="su $runas -s /bin/bash -c " # runasuser with *su*
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with *runuser*
2019-04-04 10:45:31 +00:00
# edit the values of the following lines to fit your config:
start="/usr/local/telegram-bot-bash/bashbot.sh" # location of your bashbot.sh script
name='' # your bot name as given to botfather, e.g. mysomething_bot
# END Configuration
#######################
lockfile="$(dirname $start)/lockfile"
[ "$name" = "" ] && name="$runas"
case "$1" in
'start')
$runcmd "$start start" # >/dev/null 2>&1 </dev/null
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
touch "$lockfile" >/dev/null 2>&1
fi
;;
'stop')
$runcmd "$start kill"
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
rm -f "$lockfile"
fi
;;
'status')
ps -f -u "$runas" | grep "$name" | grep -qF "bashbot.sh startbot"
if [ "$?" = "0" ]; then
2019-04-04 10:45:31 +00:00
echo "bashbot ($name) is running"
RETVAL=0
else
2019-04-04 10:45:31 +00:00
echo "bashbot ($name) is stopped"
RETVAL=1
fi
;;
'restart'|'reload')
$0 stop; $0 start
RETVAL=$?
;;
2019-04-27 13:48:03 +00:00
'restartback')
$0 suspendback; $0 resumeback
RETVAL=$?
;;
'suspendback'|'resumeback'|'killback')
$runcmd "$start $1"
RETVAL=$?
;;
*)
2019-04-27 13:48:03 +00:00
echo "Usage: $0 { start | stop | restart | reload | restartback | suspendback | resumeback | killback }"
RETVAL=1
;;
esac
exit $RETVAL