data-bot-bash is created while installing

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-01 19:01:26 +01:00
parent 23e04a98ef
commit 74dfdd753f

View File

@ -26,7 +26,7 @@
# 8 - curl/wget missing # 8 - curl/wget missing
# 10 - not bash! # 10 - not bash!
# #
#### $$VERSION$$ v1.21-pre-5-gc296899 #### $$VERSION$$ v1.21-pre-6-g23e04a9
################################################################## ##################################################################
# shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059 # shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059
@ -199,21 +199,22 @@ LOGDIR="${RUNDIR:-.}/logs"
# CREATE botconfig if not exist # CREATE botconfig if not exist
# assume everything already set up correctly if TOKEN is set # 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 # BOTCONFIG does not exist, create
printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh" [ ! -f "${BOTCONFIG}.jssh" ] && printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh"
# ask user for bot token if [ -z "$(getConfigKey "bottoken")" ]; then
if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then # ask user for bot token
if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then
printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n" printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n"
exit 2 exit 2
else else
printf "${RED}ENTER BOT TOKEN...${NN}" printf "${RED}ENTER BOT TOKEN...${NN}"
printf "${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NN}" printf "${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NN}"
read -r token read -r token
printf "\n" printf "\n"
fi
[ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh"
fi fi
[ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh"
# no botadmin, setup botadmin # no botadmin, setup botadmin
if [ -z "$(getConfigKey "botadmin")" ]; then if [ -z "$(getConfigKey "botadmin")" ]; then
# ask user for bot admin # ask user for bot admin
@ -232,10 +233,8 @@ if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then
printf "${GREY}Create initial ${BOTACL} file.${NN}" printf "${GREY}Create initial ${BOTACL} file.${NN}"
printf '\n' >"${BOTACL}" printf '\n' >"${BOTACL}"
fi fi
# setup data dir file # check data dir file
if [ ! -d "${DATADIR}" ]; then if [ ! -w "${DATADIR}" ]; then
mkdir "${DATADIR}"
elif [ ! -w "${DATADIR}" ]; then
printf "${RED}ERROR: Can't write to ${DATADIR}!.${NN}" printf "${RED}ERROR: Can't write to ${DATADIR}!.${NN}"
ls -ld "${DATADIR}" ls -ld "${DATADIR}"
exit 2 exit 2