From 63ef6781a2ac33c079d217b4850342b381b02508 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 23 Apr 2019 13:24:34 +0200 Subject: [PATCH] add simple check for correct JSON.sh and commands.sh file --- bashbot.sh | 12 ++++++++---- doc/8_custom.md | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index db8a5f3..632c2ff 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,13 +10,13 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.70-dev2-7-g1957133 +#### $$VERSION$$ v0.70-dev2-8-gf412a29 # # Exit Codes: # - 0 sucess (hopefully) # - 1 can't change to dir # - 2 can't write to tmp, count or token -# - 3 user / command not found +# - 3 user / command / file not found # - 4 unkown command # - 5 cannot connect to telegram bot @@ -62,7 +62,9 @@ if [ ! -f "${TOKENFILE}" ]; then fi fi -JSONSHFILE="${BASHBOT_JSONSH:-${RUNDIR}}/JSON.sh/JSON.sh" +JSONSHFILE="${BASHBOT_JSONSH:-${RUNDIR}/JSON.sh/JSON.sh}" +[[ "${JSONSHFILE}" != *"/JSON.sh" ]] && echo -e "${RED}ERROR: \"${JSONSHFILE}\" ends not with \"JSONS.sh\".${NC}" && exit 3 + if [ ! -f "${JSONSHFILE}" ]; then echo "Seems to be first run, Downloading ${JSONSHFILE}..." mkdir "JSON.sh" 2>/dev/null; @@ -111,7 +113,9 @@ elif [ ! -w "${COUNTFILE}" ]; then exit 2 fi -COMMANDS="${BASHBOT_COMMANDS:-${RUNDIR}}/commands.sh" +COMMANDS="${BASHBOT_COMMANDS:-${RUNDIR}/commands.sh}" +[[ "${COMMANDS}" != *".sh" ]] && echo -e "${RED}ERROR: \"${COMMANDS}\" ends not with \".sh\".${NC}" && exit 3 + if [ "$1" != "source" ]; then if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then ${CLEAR} diff --git a/doc/8_custom.md b/doc/8_custom.md index db1644e..a2c140d 100644 --- a/doc/8_custom.md +++ b/doc/8_custom.md @@ -47,6 +47,15 @@ Full path to bash script containing your commands, default: './commands.sh' export BASHBOT_COMMANDS "/etc/bashbot/bot1/commands.sh" # multibot configuration bot 1 export BASHBOT_COMMANDS "/etc/bashbot/bot2/commands.sh" # multibot configuration bot 2 ``` +#### BASHBOT_JSONSH +Full path to JSON.sh script, default: './JSON.sh/JSON.sh' +```bash + unset BASHBOT_JSONSH # telegram-bot-bash/JSON.sh/JSON.sh (default) + export BASHBOT_JSONSH "" # telegram-bot-bash/JSON.sh/JSON.sh + + export BASHBOT_JSONSH "/usr/local/bin/JSON.sh" # installed in /usr/local/bin + +``` ### Change config values @@ -122,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.70-dev2-5-gfe5840d +#### $$VERSION$$ v0.70-dev2-8-gf412a29