more save resumeback killback handling

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-20 20:48:49 +02:00
parent f1ebdbb72d
commit 8dfdf2e168
4 changed files with 34 additions and 24 deletions

View File

@ -79,9 +79,6 @@
<li><a href="doc/8_custom.md">Customize bashbot environment</a></li> <li><a href="doc/8_custom.md">Customize bashbot environment</a></li>
<li><a href="examples/README.md">Examples</a></li> <li><a href="examples/README.md">Examples</a></li>
</ul> </ul>
<h4 id="you-dont-like-the-many-bashbot-files">You dont like the many bashbot files?</h4>
<p>At the beginning bashbot was simply the file <code>bashbot.sh</code> I can copy everywhere and run the bot. Now we have commands.sh, mycommands.sh, modules/*.sh and much more.</p>
<p>Hey no Problem, if you are finished with your cool bot simply run <code>dev/make-standalone.sh</code> to create a stripped down Version containing only bashbot.sh and commands.sh! For more information see <a href="doc/7_develop.md">Create a stripped down Version of your Bot</a></p>
<h2 id="security-considerations">Security Considerations</h2> <h2 id="security-considerations">Security Considerations</h2>
<p>Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.</p> <p>Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.</p>
<p>Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. Bash programmers often struggle with quoting hell and globbing, see <a href="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a></p> <p>Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. Bash programmers often struggle with quoting hell and globbing, see <a href="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a></p>
@ -94,6 +91,7 @@
<p><strong>Your Bot configuration must no be readable from other users.</strong> Everyone who can read your Bots token can act as your Bot and has access to all chats your Bot is in!</p> <p><strong>Your Bot configuration must no be readable from other users.</strong> Everyone who can read your Bots token can act as your Bot and has access to all chats your Bot is in!</p>
<p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot Token in <code>token</code> must be protected against other users. No one exept you must have write access to the Bot files. The Bot must be restricted to have write access to <code>count</code> and <code>tmp-bot-bash</code> only, all other files must be write protected.</p> <p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot Token in <code>token</code> must be protected against other users. No one exept you must have write access to the Bot files. The Bot must be restricted to have write access to <code>count</code> and <code>tmp-bot-bash</code> only, all other files must be write protected.</p>
<p>To set access rights for your bashbot installation to a reasonable default run <code>sudo ./bashbot.sh init</code> after every update or change to your installation directory.</p> <p>To set access rights for your bashbot installation to a reasonable default run <code>sudo ./bashbot.sh init</code> after every update or change to your installation directory.</p>
<h2 id="faq">FAQ</h2>
<h3 id="is-this-bot-insecure">Is this Bot insecure?</h3> <h3 id="is-this-bot-insecure">Is this Bot insecure?</h3>
<p>Bashbot is not more (in)secure as any other Bot written in any other language, we have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks …</p> <p>Bashbot is not more (in)secure as any other Bot written in any other language, we have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks …</p>
<h3 id="why-bash-and-not-the-much-better-xyz">Why Bash and not the much better xyz?</h3> <h3 id="why-bash-and-not-the-much-better-xyz">Why Bash and not the much better xyz?</h3>
@ -104,9 +102,12 @@
<li>no need to install or learn a new programming language, library or framework</li> <li>no need to install or learn a new programming language, library or framework</li>
<li>no database, not event driven, not OO …</li> <li>no database, not event driven, not OO …</li>
</ul> </ul>
<h4 id="can-i-have-the-single-bashbot.sh-file-back">Can I have the single bashbot.sh file back?</h4>
<p>At the beginning bashbot was simply the file <code>bashbot.sh</code> you can copy everywhere and run the bot. Now we have commands.sh, mycommands.sh, modules/*.sh and much more.</p>
<p>Hey no Problem, if you are finished with your cool bot run <code>dev/make-standalone.sh</code> to create a stripped down Version of your bot containing only bashbot.sh and commands.sh! For more information see <a href="doc/7_develop.md">Create a stripped down Version of your Bot</a></p>
<p><span class="citation">@Gnadelwartz</span></p> <p><span class="citation">@Gnadelwartz</span></p>
<h2 id="thats-it">Thats it!</h2> <h2 id="thats-it">Thats it!</h2>
<p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p> <p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p>
<h4 id="version-v0.80-pre-0-gdd7c66d"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.80-pre-0-gdd7c66d</h4> <h4 id="version-v0.80-pre-8-gf1ebdbb"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.80-pre-8-gf1ebdbb</h4>
</body> </body>
</html> </html>

View File

@ -59,12 +59,6 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
* [Examples](examples/README.md) * [Examples](examples/README.md)
#### You don't like the many bashbot files?
At the beginning bashbot was simply the file ```bashbot.sh``` I can copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.
Hey no Problem, if you are finished with your cool bot simply run ```dev/make-standalone.sh``` to create a stripped down Version containing only
'bashbot.sh' and 'commands.sh'! For more information see [Create a stripped down Version of your Bot](doc/7_develop.md)
## Security Considerations ## Security Considerations
Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot. Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.
@ -89,6 +83,8 @@ Everyone with read access to your Bot files can extract your Bots data. Especial
To set access rights for your bashbot installation to a reasonable default run ```sudo ./bashbot.sh init``` after every update or change to your installation directory. To set access rights for your bashbot installation to a reasonable default run ```sudo ./bashbot.sh init``` after every update or change to your installation directory.
## FAQ
### Is this Bot insecure? ### Is this Bot insecure?
Bashbot is not more (in)secure as any other Bot written in any other language, we have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks ... Bashbot is not more (in)secure as any other Bot written in any other language, we have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks ...
@ -100,10 +96,17 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from
- no need to install or learn a new programming language, library or framework - no need to install or learn a new programming language, library or framework
- no database, not event driven, not OO ... - no database, not event driven, not OO ...
#### Can I have the single bashbot.sh file back?
At the beginning bashbot was simply the file ```bashbot.sh``` you can copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.
Hey no Problem, if you are finished with your cool bot run ```dev/make-standalone.sh``` to create a stripped down Version of your bot containing only
'bashbot.sh' and 'commands.sh'! For more information see [Create a stripped down Version of your Bot](doc/7_develop.md)
@Gnadelwartz @Gnadelwartz
## That's it! ## That's it!
If you feel that there's something missing or if you found a bug, feel free to submit a pull request! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.80-pre-0-gdd7c66d #### $$VERSION$$ v0.80-pre-8-gf1ebdbb

View File

@ -71,16 +71,6 @@ all](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
* [Examples](examples/README.md) * [Examples](examples/README.md)
#### You don't like the many bashbot files?
At the beginning bashbot was simply the file ```bashbot.sh``` I can copy
everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh',
'modules/*.sh' and much more.
Hey no Problem, if you are finished with your cool bot simply run
```dev/make-standalone.sh``` to create a stripped down Version containing only
'bashbot.sh' and 'commands.sh'! For more information see [Create a stripped
down Version of your Bot](doc/7_develop.md)
## Security Considerations ## Security Considerations
Running a Telegram Bot means it is connected to the public and you never know Running a Telegram Bot means it is connected to the public and you never know
whats send to your Bot. whats send to your Bot.
@ -131,6 +121,8 @@ To set access rights for your bashbot installation to a reasonable default run
```sudo ./bashbot.sh init``` after every update or change to your installation ```sudo ./bashbot.sh init``` after every update or change to your installation
directory. directory.
## FAQ
### Is this Bot insecure? ### Is this Bot insecure?
Bashbot is not more (in)secure as any other Bot written in any other language, Bashbot is not more (in)secure as any other Bot written in any other language,
we have done our best to make it as secure as possible. But YOU are responsible we have done our best to make it as secure as possible. But YOU are responsible
@ -147,6 +139,18 @@ health status
- no need to install or learn a new programming language, library or framework - no need to install or learn a new programming language, library or framework
- no database, not event driven, not OO ... - no database, not event driven, not OO ...
#### Can I have the single bashbot.sh file back?
At the beginning bashbot was simply the file ```bashbot.sh``` you can copy
everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh',
'modules/*.sh' and much more.
Hey no Problem, if you are finished with your cool bot run
```dev/make-standalone.sh``` to create a stripped down Version of your bot
containing only
'bashbot.sh' and 'commands.sh'! For more information see [Create a stripped
down Version of your Bot](doc/7_develop.md)
@Gnadelwartz @Gnadelwartz
## That's it! ## That's it!
@ -154,4 +158,4 @@ health status
If you feel that there's something missing or if you found a bug, feel free to If you feel that there's something missing or if you found a bug, feel free to
submit a pull request! submit a pull request!
#### $$VERSION$$ v0.80-pre-0-gdd7c66d #### $$VERSION$$ v0.80-pre-8-gf1ebdbb

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.80-pre-7-g300553f #### $$VERSION$$ v0.80-pre-8-gf1ebdbb
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -543,6 +543,7 @@ if [ "$1" != "source" ]; then
exit exit
;; ;;
"backgr"* | "resumeb"*) "backgr"* | "resumeb"*)
_is_function start_proc || { echo -e "${RED}Module background not availible.${NC}"; exit 3; }
echo -e "${GREEN}Restart background processes ...${NC}" echo -e "${GREEN}Restart background processes ...${NC}"
for FILE in "${TMPDIR:-.}/"*-back.cmd; do for FILE in "${TMPDIR:-.}/"*-back.cmd; do
if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then
@ -555,11 +556,12 @@ if [ "$1" != "source" ]; then
JOB="${JOB%:*}" JOB="${JOB%:*}"
fifo="$(procname "${CHAT[ID]}" "back-${JOB}-")" fifo="$(procname "${CHAT[ID]}" "back-${JOB}-")"
echo "restart background job ${PROG} ${fifo}" echo "restart background job ${PROG} ${fifo}"
start_back "${CHAT[ID]}" "${PROG}" "${JOB}" start_proc "${CHAT[ID]}" "${PROG}" "back-${JOB}-"
fi fi
done done
;; ;;
"killb"* | "suspendb"*) "killb"* | "suspendb"*)
_is_function start_proc || { echo -e "${RED}Module background not availible.${NC}"; exit 3; }
echo -e "${GREEN}Stopping background processes ...${NC}" echo -e "${GREEN}Stopping background processes ...${NC}"
for FILE in "${TMPDIR:-.}/"*-back.cmd; do for FILE in "${TMPDIR:-.}/"*-back.cmd; do
if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then