fix restart in rc file, add init command to setup bashbot environment

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-03-25 11:11:22 +01:00
parent eff4a68c70
commit 474a010670
2 changed files with 21 additions and 9 deletions

View File

@ -4,6 +4,11 @@ A Telegram bot written in bash.
Depends on [tmux](http://github.com/tmux/tmux). Depends on [tmux](http://github.com/tmux/tmux).
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh). Uses [JSON.sh](http://github.com/dominictarr/JSON.sh).
Written by Drew (@topkecleon) and Daniil Gentili (@danogentili).
Also contributed: JuanPotato, BigNerd95, TiagoDanin, iicc1, Kay M (@gnadelwartz).
[Download from github](https://github.com/topkecleon/telegram-bot-bash)
Released to the public domain wherever applicable. Released to the public domain wherever applicable.
Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/). Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/).
@ -69,13 +74,19 @@ group. This step is up to you actually.
13. @botfather replies with `Success! The new status is: DISABLED. /help` 13. @botfather replies with `Success! The new status is: DISABLED. /help`
### Install bashbot ### Install bashbot
Clone the repository: 1. Go to the directory you want to install bashbot, e.g.
- your $HOME directory (install and run with your user-ID)
- /usr/local if you want to run as service
2. Clone the repository:
``` ```
git clone --recursive https://github.com/topkecleon/telegram-bot-bash git clone --recursive https://github.com/topkecleon/telegram-bot-bash
``` ```
3. Change to directory ```telegram-bot.bash``` and run ```./bashbot.sh init``` and follow the instructions.
Create a file called token and paste the token in there.
Then start editing the commands. Then start editing the commands.sh.
### Receive data ### Receive data
You can read incoming data using the following variables: You can read incoming data using the following variables:

View File

@ -11,7 +11,7 @@
### END INIT INFO ### END INIT INFO
runas="root" # not recommended! runas="root" # not recommended!
runcmd="echo" # not activated until you edit lines below runcmd="echo" # not actived until you edit lines below
# uncomment the next line to run as other user, e.g. www # uncomment the next line to run as other user, e.g. www
# runas="www" # runas="www"
@ -20,10 +20,10 @@ runcmd="echo" # not activated until you edit lines below
# runcmd="su $runas -s /bin/bash -c " # runasuser with su # runcmd="su $runas -s /bin/bash -c " # runasuser with su
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with runuser # runcmd="runuser $runas -s /bin/bash -c " # runasuser with runuser
# uncomment and adjust the the values of the following lines # adjust the the values of the following lines
# start="/usr/local/telegram-bot-bash/bashbot.sh" start="/usr/local/telegram-bot-bash/bashbot.sh"
# lockfile=/usr/local/telegram-bot-bash/lockfile lockfile=/usr/local/telegram-bot-bash/lockfile
# name='new-session' # telegram name of your bot name='new-session' # telegram name of your bot
case "$1" in case "$1" in
@ -52,11 +52,12 @@ case "$1" in
fi fi
;; ;;
'restart'|'reload') 'restart'|'reload')
$stop ; $start $0 stop; $0 start
RETVAL=$? RETVAL=$?
;; ;;
'suspendback'|'resumeback'|'killback') 'suspendback'|'resumeback'|'killback')
$runcmd "$start $1" $runcmd "$start $1"
RETVAL=$?
;; ;;
*) *)
echo "Usage: $0 { start | stop | restart | reload | suspendback | resumeback | killback }" echo "Usage: $0 { start | stop | restart | reload | suspendback | resumeback | killback }"