currently no update actions on init

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-27 15:12:35 +01:00
parent 0d7fee3bd2
commit 3f8841b8f1

View File

@ -26,7 +26,7 @@
# 8 - curl/wget missing # 8 - curl/wget missing
# 10 - not bash! # 10 - not bash!
# #
#### $$VERSION$$ v1.21-dev-12-g21afd4e #### $$VERSION$$ v1.21-dev-13-g0d7fee3
################################################################## ##################################################################
# shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059 # shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059
@ -1111,13 +1111,10 @@ bot_init() {
[ -n "${BASHBOT_HOME}" ] && cd "${BASHBOT_HOME}" || exit 1 [ -n "${BASHBOT_HOME}" ] && cd "${BASHBOT_HOME}" || exit 1
local DEBUG="$1" local DEBUG="$1"
# upgrade from old version # upgrade from old version
# currently no action
printf "Check for Update actions ...\n" printf "Check for Update actions ...\n"
local OLDTMP="${BASHBOT_VAR:-.}/tmp-bot-bash"
[ -d "${OLDTMP}" ] && { mv -n "${OLDTMP}/"* "${DATADIR}"; rmdir "${OLDTMP}"; }
# no more existing modules
[ -f "modules/inline.sh" ] && rm -f "modules/inline.sh"
# load addons on startup
printf "Done.\n" printf "Done.\n"
# load addons on startup
printf "Initialize modules and addons ...\n" printf "Initialize modules and addons ...\n"
for addons in "${ADDONDIR:-.}"/*.sh ; do for addons in "${ADDONDIR:-.}"/*.sh ; do
# shellcheck source=./modules/aliases.sh # shellcheck source=./modules/aliases.sh
@ -1142,19 +1139,15 @@ bot_init() {
printf "${RED}User \"$TOUSER\" not found!${NN}" printf "${RED}User \"$TOUSER\" not found!${NN}"
exit 3 exit 3
else else
# shellcheck disable=SC2009
oldbot="$(ps -fu "$TOUSER" | grep startbot | grep -v -e 'grep' -e '\-startbot' )"
[ -n "${oldbot}" ] && \
printf "${ORANGE}Warning: At least one not upgraded TMUX bot is running! You must stop it with kill command:${NN}${oldbot}\n"
printf "Adjusting files and permissions for user \"${TOUSER}\" ...\n" printf "Adjusting files and permissions for user \"${TOUSER}\" ...\n"
[ -w "bashbot.rc" ] && sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' "bashbot.rc" [ -w "bashbot.rc" ] && sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' "bashbot.rc"
chown -R "$TOUSER" . ./*
chmod 711 . chmod 711 .
chmod -R o-w ./* chmod -R o-w ./*
chmod -R u+w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${BOTADMIN}" logs "${LOGDIR}/"*.log 2>/dev/null chmod -R u+w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${BOTADMIN}" logs "${LOGDIR}/"*.log 2>/dev/null
chmod -R o-r,o-w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${TOKENFILE}" "${BOTADMIN}" "${BOTACL}" 2>/dev/null chmod -R o-r,o-w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${TOKENFILE}" "${BOTADMIN}" "${BOTACL}" 2>/dev/null
# jsshDB must writeable by owner # jsshDB must writeable by owner
find . -name '*.jssh*' -exec chmod u+w \{\} + find . -name '*.jssh*' -exec chmod u+w \{\} +
chown -R "$TOUSER" . ./*
printf "Done.\n" printf "Done.\n"
fi fi
# ask to check bottoken online # ask to check bottoken online
@ -1166,10 +1159,10 @@ bot_init() {
$0 botname $0 botname
fi fi
fi fi
# check if botconf if seems valid # check if botconf seems valid
printf "${GREEN}This is your bot config:${NN}" printf "${GREEN}This is your bot config:${NN}"
sed 's/^/\t/' "${BOTCONFIG}.jssh" | grep -vF '["bot_config_key"]' sed 's/^/\t/' "${BOTCONFIG}.jssh" | grep -vF '["bot_config_key"]'
if [[ "$(getConfigKey "bottoken")" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ && "$(getConfigKey "botadmin")" =~ ^[0-9]+$ ]]; then if check_token "$(getConfigKey "bottoken")" && [[ "$(getConfigKey "botadmin")" =~ ^[0-9]+$ ]]; then
printf "Bot config seems to be valid. Should I make a backup copy? (Y/n) Y\b" printf "Bot config seems to be valid. Should I make a backup copy? (Y/n) Y\b"
read -r ANSWER read -r ANSWER
if [[ -z "${ANSWER}" || "${ANSWER}" =~ ^[^Nn] ]]; then if [[ -z "${ANSWER}" || "${ANSWER}" =~ ^[^Nn] ]]; then
@ -1177,7 +1170,7 @@ bot_init() {
cp "${BOTCONFIG}.jssh" "${BOTCONFIG}.jssh.ok" cp "${BOTCONFIG}.jssh" "${BOTCONFIG}.jssh.ok"
fi fi
else else
printf "${ORANGE}Bot config may not complete, pls check.${NN}" printf "${ORANGE}Bot config may incomplete, pls check.${NN}"
fi fi
# show result # show result
ls -ld "${DATADIR}" "${LOGDIR}" ./*.jssh* ./*.sh 2>/dev/null ls -ld "${DATADIR}" "${LOGDIR}" ./*.jssh* ./*.sh 2>/dev/null