explain to use sudo with bashbot.rc
This commit is contained in:
parent
c075ea601e
commit
7a1c01dfb1
39
README.md
39
README.md
|
@ -386,29 +386,46 @@ E.g. the Emoticons ``` 😁 😘 ❤️ 😊 👍 ``` are encoded as:
|
|||
Bashbot is desingned to run manually by the user who installed it. Nevertheless it's possible to run it by an other user-ID, as a system service or sceduled from cron. This is onyl recommended for experiend linux users.
|
||||
|
||||
### Run as other user or system service
|
||||
Running bashbot as an other user is only possible (and strongly recommended) for root.
|
||||
Running bashbot as an other user is only possibleers with sudo rigths.
|
||||
|
||||
Setup the environment for the user you want to run bashbot and enter new username:
|
||||
Setup the environment for the user you want to run bashbot and enter desired username, e.g. nobody :
|
||||
```bash
|
||||
./bashbot.sh init
|
||||
```
|
||||
|
||||
Edit the example rc file ```bashbot.rc```, uncomment the ```runcmd``` availible on your system and fill the name of your Bot in ```name```.
|
||||
Edit the example file ```bashbot.rc```, uncomment the ```runcmd=``` availible on your system and edit the following lines to fit xyour configuration:
|
||||
```
|
||||
#######################
|
||||
# Configuration Section
|
||||
|
||||
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
|
||||
runas="nobody"
|
||||
|
||||
# uncomment one of the following lines
|
||||
# runcmd="su $runas -s /bin/bash -c " # runasuser with su
|
||||
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with runuser
|
||||
|
||||
# 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
|
||||
#######################
|
||||
```
|
||||
From now on always use bashbot.rc to start/stop your bot:
|
||||
```bash
|
||||
./bashbot.rc start
|
||||
sudo ./bashbot.rc start
|
||||
```
|
||||
Type ```ps -ef | grep bashbot``` to verify your Bot is running as the desired user.
|
||||
|
||||
If you started bashbot by bashbot.rc you must use bashbot.rc also to manage your Bot! The following commands are availible:
|
||||
```bash
|
||||
./bashbot.rc start
|
||||
./bashbot.rc stop
|
||||
./bashbot.rc status
|
||||
./bashbot.rc suspendback
|
||||
./bashbot.rc resumeback
|
||||
./bashbot.rc killback
|
||||
sudo ./bashbot.rc start
|
||||
sudo ./bashbot.rc stop
|
||||
sudo ./bashbot.rc status
|
||||
sudo ./bashbot.rc suspendback
|
||||
sudo ./bashbot.rc resumeback
|
||||
sudo ./bashbot.rc killback
|
||||
```
|
||||
To change back the environment to your user-ID run ```./bashbot.rc init``` again and enter your user name.
|
||||
|
||||
|
@ -445,4 +462,4 @@ No - its not less (in)secure as any other Bot written in any other language. But
|
|||
|
||||
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.5-rc-4-g92e9e9c
|
||||
#### $$VERSION$$ v0.5-rc-7-gc075ea6
|
||||
|
|
34
bashbot.rc
34
bashbot.rc
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# description: Start or stop telegram-bash-bot
|
||||
#
|
||||
#### $$VERSION$$ v0.5-rc-5-g352c64f
|
||||
#### $$VERSION$$ v0.5-rc-7-gc075ea6
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: bashbot
|
||||
|
@ -12,22 +12,30 @@
|
|||
# Description: Start or stop telegram-bot-bash server
|
||||
### END INIT INFO
|
||||
|
||||
# save default values
|
||||
TERM="" # disable bashbot clear and color output
|
||||
runas="root" # not recommended!
|
||||
runas="nobody" # not recommended!
|
||||
runcmd="echo Dry run:" # not actived until you edit lines below
|
||||
|
||||
# uncomment the next line to run as other user, e.g. www
|
||||
# runas="nobody"
|
||||
#######################
|
||||
# Configuration Section
|
||||
|
||||
# uncomment one of the following lines
|
||||
# runcmd="su $runas -s /bin/bash -c " # runasuser with su
|
||||
# runcmd="runuser $runas -s /bin/bash -c " # runasuser with runuser
|
||||
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
|
||||
runas="nobody"
|
||||
|
||||
# adjust the the values of the following lines
|
||||
start="/usr/local/telegram-bot-bash/bashbot.sh"
|
||||
lockfile=/usr/local/telegram-bot-bash/lockfile
|
||||
name='new-session' # telegram name of your bot
|
||||
# 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*
|
||||
|
||||
# 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')
|
||||
|
@ -47,10 +55,10 @@ case "$1" in
|
|||
'status')
|
||||
ps -f -u "$runas" | grep "$name" | grep -qF "bashbot.sh startbot"
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "$name is running"
|
||||
echo "bashbot ($name) is running"
|
||||
RETVAL=0
|
||||
else
|
||||
echo "$name is stopped"
|
||||
echo "bashbot ($name) is stopped"
|
||||
RETVAL=1
|
||||
fi
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue