save corrupt bot config on recover

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-27 13:12:38 +01:00
parent 90c5d87761
commit 9bfc27a678

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v1.21-dev-8-gc0bce91 #### $$VERSION$$ v1.21-dev-9-g90c5d87
# #
# Exit Codes: # Exit Codes:
# - 0 success (hopefully) # - 0 success (hopefully)
@ -266,10 +266,11 @@ if [ -z "${BOTTOKEN}" ]; then
printf "${ORANGE}${BOTERROR}${NC} " printf "${ORANGE}${BOTERROR}${NC} "
if [ -r "${BOTCONFIG}.jssh.ok" ]; then if [ -r "${BOTCONFIG}.jssh.ok" ]; then
log_error "${BOTERROR}" log_error "${BOTERROR}"
mv "${BOTCONFIG}.jssh" "${BOTCONFIG}.jssh.bad"
cp "${BOTCONFIG}.jssh.ok" "${BOTCONFIG}.jssh"; printf "OK\n" cp "${BOTCONFIG}.jssh.ok" "${BOTCONFIG}.jssh"; printf "OK\n"
BOTTOKEN="$(getConfigKey "bottoken")" BOTTOKEN="$(getConfigKey "bottoken")"
else else
printf "\n${RED}Error: Missing bot token! remove ${BOTCONFIG}.jssh and run \"bashbot.sh init\" may fix it.${NN}" printf "\n${RED}Error: Can't recover from missing bot token! Remove ${BOTCONFIG}.jssh and run${NC} bashbot.sh init\n"
exit 7 exit 7
fi fi
fi fi