From 74dfdd753f8a79fe16d57894f123aa9ecce836c1 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 1 Jan 2021 19:01:26 +0100 Subject: [PATCH] data-bot-bash is created while installing --- bashbot.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 076c34d..f1f69c2 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -26,7 +26,7 @@ # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.21-pre-5-gc296899 +#### $$VERSION$$ v1.21-pre-6-g23e04a9 ################################################################## # shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059 @@ -199,21 +199,22 @@ LOGDIR="${RUNDIR:-.}/logs" # CREATE botconfig if not exist # assume everything already set up correctly if TOKEN is set -if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then +if [ -z "${BOTTOKEN}" ]; then # BOTCONFIG does not exist, create - printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh" - # ask user for bot token - if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then + [ ! -f "${BOTCONFIG}.jssh" ] && printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh" + if [ -z "$(getConfigKey "bottoken")" ]; then + # ask user for bot token + if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n" exit 2 - else + else printf "${RED}ENTER BOT TOKEN...${NN}" printf "${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NN}" read -r token printf "\n" + fi + [ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh" fi - [ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh" - # no botadmin, setup botadmin if [ -z "$(getConfigKey "botadmin")" ]; then # ask user for bot admin @@ -232,10 +233,8 @@ if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then printf "${GREY}Create initial ${BOTACL} file.${NN}" printf '\n' >"${BOTACL}" fi - # setup data dir file - if [ ! -d "${DATADIR}" ]; then - mkdir "${DATADIR}" - elif [ ! -w "${DATADIR}" ]; then + # check data dir file + if [ ! -w "${DATADIR}" ]; then printf "${RED}ERROR: Can't write to ${DATADIR}!.${NN}" ls -ld "${DATADIR}" exit 2