bashbot.rc: fix webhook

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-03-02 18:26:41 +01:00
parent 7b8e391479
commit 4854d0d051
2 changed files with 18 additions and 15 deletions

View File

@ -5,9 +5,10 @@
#
# tested on: ubuntu, opensuse, debian
#
#### $$VERSION$$ v1.45-dev-60-g2415814
#### $$VERSION$$ v1.45-dev-61-g7b8e391
# shellcheck disable=SC2009
# shellcheck disable=SC2181
# shellcheck disable=SC2250
#
### BEGIN INIT INFO
@ -27,21 +28,21 @@ runcmd="echo Dry run:" # not activated until you edit lines below
# Configuration Section
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
runas="nobody"
runas="www"
# uncomment one of the example 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*
runcmd="/usr/sbin/runuser ${runas} -s /bin/bash -c " # runasuser with *runuser*
# edit the values of the following lines to fit your config:
# your bot name as given to botfather, e.g. mysomething_bot
name=""
name="GnadelTest_bot"
# your bot installation dir
bashbotdir="/usr/local/telegram-bot-bash"
bashbotdir="/usr/local/github/telegram-bot-bash-develop/DIST/telegram-bot-bash"
databotdir="${bashbotdir}/data-bot-bash"
# programs to run
bashbot="cd ${bashbotdir}; ${bashbotdir}/bashbot.sh"
webhook="cd ${bashbotdir}; ${bashbotdir}/bin/process_batch.sh --start --watch ${databotdir}/webhook-fifo-${name}"
webhook="cd ${bashbotdir}; ${bashbotdir}/bin/process_batch.sh --startbot --watch ${databotdir}/webhook-fifo-${name} &"
# set additionl parameter, e.g. debug
mode=""
@ -52,32 +53,34 @@ mode=""
case "$1" in
'start')
# shellcheck disable=SC2250
$runcmd "$bashbot start $mode" # >/dev/null 2>&1 </dev/null
RETVAL=$?
;;
'starthook')
# shellcheck disable=SC2250
$runcmd "$webhook $mode" # >/dev/null 2>&1 </dev/null
sleep 1
$0 status
RETVAL=$?
;;
'stop')
# shellcheck disable=SC2250
$runcmd "$bashbot stop $mode"
RETVAL=$?
;;
'stophook')
# shellcheck disable=SC2250
pkill -u "${runas}" "process_batch.sh"
KILLID="$(ps -f -u "${runas}" | grep "process_batch.sh --startbot" | sed -E 's/[^0-9]+([0-9]+).*/\1/')"
if [ -n "${KILLID}" ]; then
$runcmd "kill $(printf "%s" "${KILLID}" | tr -s "\r\n" " " )"
$0 status
fi
RETVAL=$?
;;
'status')
ps -f -u "${runas}" | grep "${name}" | grep -qF "process_batch.sh --start --watch"
ps -f -u "${runas}" | grep "${name}" | grep -qF "bashbot.sh startbot"
if [ "$?" = "0" ]; then
printf "bashbot (%s) is running in poll mode\n" "${name}"
RETVAL=0
else
ps -f -u "${runas}" | grep "${name}" | grep -qF ""
ps -f -u "${runas}" | grep "${name}" | grep -qF "process_batch.sh --startbot"
if [ "$?" = "0" ]; then
printf "bashbot (%s) is running in webhook mode\n" "${name}"
RETVAL=0

View File

@ -21,7 +21,7 @@ USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n]
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 27.02.2021 13:14
#
#### $$VERSION$$ v1.45-dev-55-g5dd24c3
#### $$VERSION$$ v1.45-dev-60-g2415814
#===============================================================================
####
@ -30,7 +30,7 @@ COMMAND="process_multi_updates"
lines="-n 10"
opt=0
while [[ "$opt" -lt 5 && "$1" == "-"* ]]
while [[ "${opt}" -lt 5 && "$1" == "-"* ]]
do
(( opt++ ))
case "$1" in