From 3b25adfeb2d91f980a5fd90c3e0f5a3adbee7ff5 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 18 Mar 2019 22:19:44 +0100 Subject: [PATCH] add command line option to kill all background jobs --- bashbot.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bashbot.sh b/bashbot.sh index 8a69510..bc8aafb 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -504,6 +504,23 @@ case "$1" in send_markdown_message "${CHAT[ID]}" "*Bot stopped*" echo -e '\e[0;32mOK. Bot stopped successfully.\e[0m' ;; + "killback") + clear + echo -e "\e[0;32mRemove background processes ...\e[0m" + for FILE in ${TMPDIR}/*-back.cmd; do + if [ "$FILE" == "${TMPDIR}/*-back.cmd" ]; then + echo -e "\e[0;31mNo background processes.\e[0m"; break + else + REMOVE="$(cat "$FILE")" + CHAT[ID]="${REMOVE%%:*}" + JOB="${REMOVE#*:}" + fifo="back-${JOB%:*}-${ME}_${REMOVE%%:*}" + echo "killbackground ${fifo}" + rm $FILE + ( tmux kill-session -t "${fifo}"; tmux kill-session -t sendprocess_${fifo}; rm -r $TMPDIR/${fifo}) 2>/dev/null + fi + done + ;; "help") clear less README.md @@ -516,7 +533,7 @@ case "$1" in ;; *) echo -e '\e[0;31mBAD REQUEST\e[0m' - echo -e '\e[0;31mAvailable arguments: outproc, count, broadcast, start, background, kill, help, attach\e[0m' + echo -e '\e[0;31mAvailable arguments: outproc, count, broadcast, start, background, kill, killback, help, attach\e[0m' ;; esac