From 050d376f28cbad2f0a641f6951091a9828af0a14 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 31 Mar 2019 12:12:55 +0200 Subject: [PATCH] bashbot 0.5 Release Candidate --- README.md | 2 +- bashbot.cron | 6 +++--- bashbot.rc | 2 +- bashbot.sh | 25 ++++++++++++------------- commands.sh | 2 +- notify | 2 +- question | 2 +- version | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 9751fbf..09e2406 100644 --- a/README.md +++ b/README.md @@ -445,4 +445,4 @@ No - its not more or less insecure as any other Bot written in any other languag If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc diff --git a/bashbot.cron b/bashbot.cron index 4a5af80..91d811e 100644 --- a/bashbot.cron +++ b/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc SHELL=/bin/sh @@ -28,9 +28,9 @@ MAILTO=root # * * * * * root echo "run every minute!" # run as www every day at 0:00 - 0 0 * * * nobody /usr/local/telegram-bot-bash/bashbot.sh start # (re)start bot + 0 0 * * * nobody /usr/local/telegram-bot-bash/bashbot.sh start # (re)start bot 0 0 * * * nobody /usr/local/telegram-bot-bash/bashbot.sh resumeback # (re)start background jobs # run as www on 24 of Dec, 12:00 - 0 12 24 12 * nobody /usr/local/telegram-bot-bash/bashbot.sh broadcast "X-Mas shopping is over!" # broadcast qa message + 0 12 24 12 * nobody /usr/local/telegram-bot-bash/bashbot.sh broadcast "X-Mas shopping is over!" # broadcast a message diff --git a/bashbot.rc b/bashbot.rc index 9f71898..1cb8bdf 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc # ### BEGIN INIT INFO # Provides: bashbot diff --git a/bashbot.sh b/bashbot.sh index b3aa9d8..0c45a26 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,15 +10,10 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.49-9-gb27017f - -# get location of bashbot.sh an change to bashbot dir -SCRIPT="./$(basename $0)" -SCRIPTDIR="$(dirname $0)" -cd "${SCRIPTDIR}" +#### $$VERSION$$ v0.5-rc-0-g0c144bc # are we runnig in a terminal? -if [ -t 1 ] || [ "$TERM" != "" ]; then +if [ -t 1 ] && [ "$TERM" != "" ]; then CLEAR='clear' RED='\e[31m' GREEN='\e[32m' @@ -26,6 +21,10 @@ if [ -t 1 ] || [ "$TERM" != "" ]; then NC='\e[0m' fi +# get location of bashbot.sh an change to bashbot dir +SCRIPT="./$(basename $0)" +SCRIPTDIR="$(dirname $0)" +cd "${SCRIPTDIR}" || echo -e "${RED}ERROR: Can't change to ${SCRIPTDIR} ...${NC}" && exit 1 if [ ! -w "." ]; then echo -e "${ORANGE}WARNING: $SCRIPTDIR is not writeable!${NC}" @@ -61,7 +60,7 @@ if [ ! -f "$COUNT" ]; then touch "$COUNT" elif [ ! -w "$COUNT" ]; then $CLEAR - echo -e "${RED}ERROR: can't write to $COUNT!.${NC}" + echo -e "${RED}ERROR: Can't write to $COUNT!.${NC}" ls -l "$COUNT" exit 1 fi @@ -550,7 +549,7 @@ case "$1" in echo -e "${RED}User \"$TOUSER\" not found!${NC}" exit 2 else - echo "Ajusting user in bashbot.rc ..." + echo "Adjusting user in bashbot.rc ..." sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' bashbot.rc echo "Adjusting Owner and Permissions ..." chown -R "$TOUSER" . * @@ -565,7 +564,7 @@ case "$1" in "background" | "resumeback") $CLEAR 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 echo -e "${RED}No background processes to start.${NC}"; break else @@ -578,8 +577,8 @@ case "$1" in echo "restartbackground ${PROG} ${fifo}" ( tmux kill-session -t "${fifo}"; tmux kill-session -t sendprocess_${fifo}; rm -f -r $TMPDIR/${fifo}) 2>/dev/null mkfifo "$TMPDIR/${fifo}" - TMUX= tmux new-session -d -s "${fifo}" "${PROGi}" &>"$TMPDIR/${fifo}"; echo "imprettydarnsuredatdisisdaendofdacmd" >"$TMPDIR/${fifo}" - TMUX= tmux new-session -d -s "sendprocess_${fifo}" "bash $SCRIPT outproc ${CHAT[ID]} ${fifo}" + TMUX= tmux new-session -d -s "${fifo}" "${PROG} &>$TMPDIR/${fifo}; echo imprettydarnsuredatdisisdaendofdacmd>$TMPDIR/${fifo}" + TMUX= tmux new-session -d -s sendprocess_${fifo} "bash $SCRIPT outproc ${CHAT[ID]} ${fifo}" fi done ;; @@ -592,7 +591,7 @@ case "$1" in "killback" | "suspendback") $CLEAR 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 echo -e "${RED}No background processes.${NC}"; break else diff --git a/commands.sh b/commands.sh index 264e7c9..b70729a 100755 --- a/commands.sh +++ b/commands.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc # adjust your language setting here, e.g.when run from other user or cron. # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/notify b/notify index 347b395..69822cd 100755 --- a/notify +++ b/notify @@ -2,7 +2,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/question index 62edfbf..7b25b8c 100755 --- a/question +++ b/question @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/version b/version index 0f23783..90f1b3a 100755 --- a/version +++ b/version @@ -1,6 +1,6 @@ #!/bin/sh # -#### $$VERSION$$ v0.49-4-g8e08c1f +#### $$VERSION$$ v0.5-rc-0-g0c144bc # # Easy Versioning in git: #