some test optimisations

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-02 00:11:23 +01:00
parent 652398e29f
commit 05b81ff31d
1 changed files with 13 additions and 26 deletions

View File

@ -30,7 +30,7 @@
# 8 - curl/wget missing # 8 - curl/wget missing
# 10 - not bash! # 10 - not bash!
# #
#### $$VERSION$$ v1.21-pre-13-g9cca55b #### $$VERSION$$ v1.21-pre-17-g652398e
################################################################## ##################################################################
# emmbeded system may claim bash but it is not # emmbeded system may claim bash but it is not
@ -173,20 +173,15 @@ esac
if [[ -z "${SOURCE}" && -z "$BASHBOT_HOME" ]] && ! cd "${RUNDIR}" ; then if [[ -z "${SOURCE}" && -z "$BASHBOT_HOME" ]] && ! cd "${RUNDIR}" ; then
printf "${RED}ERROR: Can't change to ${RUNDIR} ...${NN}" printf "${RED}ERROR: Can't change to ${RUNDIR} ...${NN}"
exit 1 exit 1
else
RUNDIR="."
fi
if [ ! -w "." ]; then
printf "${ORANGE}WARNING: ${RUNDIR} is not writeable!${NN}"
ls -ld .
fi fi
RUNDIR="."
[ ! -w "." ] && printf "${ORANGE}WARNING: ${RUNDIR} is not writeable!${NN}"
# check if JSON.sh is available # check if JSON.sh is available
JSONSHFILE="${BASHBOT_JSONSH:-${SCRIPTDIR}/JSON.sh/JSON.sh}" JSONSHFILE="${BASHBOT_JSONSH:-${SCRIPTDIR}/JSON.sh/JSON.sh}"
[ ! -x "${JSONSHFILE}" ] &&\ [ ! -x "${JSONSHFILE}" ] &&\
printf "${RED}ERROR:${NC} ${JSONSHFILE} ${RED}does not exist, are we in dev environment?${NN}${GREY}%s${NN}\n"\ printf "${RED}ERROR:${NC} ${JSONSHFILE} ${RED}does not exist, are we in dev environment?${NN}${GREY}%s${NN}\n"\
"\$JSONSHFILE is set wrong or bashbot is not installed correctly, see doc/0_install.md" && exit 3 "\$JSONSHFILE is set wrong or bashbot is not installed correctly, see doc/0_install.md" && exit 3
# file locations based on ENVIRONMENT # file locations based on ENVIRONMENT
BOTCONFIG="${BASHBOT_ETC:-.}/botconfig" BOTCONFIG="${BASHBOT_ETC:-.}/botconfig"
@ -318,21 +313,18 @@ export res CAPTION ME
################## ##################
# read commands file if we are not sourced # read commands file if we are not sourced
COMMANDS="${BASHBOT_ETC:-.}/commands.sh" COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
if [ -z "${SOURCE}" ]; then if [ -r "${COMMANDS}" ]; then
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then # shellcheck source=./commands.sh
printf "${RED}ERROR: ${COMMANDS} does not exist or is not readable!.${NN}" source "${COMMANDS}" "source"
ls -l "${COMMANDS}" else
exit 3 [ -z "${SOURCE}" ] && printf "${RED}Warning: ${COMMANDS} does not exist or is not readable!.${NN}"
fi
fi fi
# shellcheck source=./commands.sh
[ -r "${COMMANDS}" ] && source "${COMMANDS}" "source"
############### ###############
# load modules # load modules
for modules in "${MODULEDIR:-.}"/*.sh ; do for module in "${MODULEDIR:-.}"/*.sh ; do
# shellcheck source=./modules/aliases.sh # shellcheck source=./modules/aliases.sh
if ! _is_function "$(basename "${modules}")" && [ -r "${modules}" ]; then source "${modules}" "source"; fi if ! _is_function "$(basename "${module}")" && [ -r "${module}" ]; then source "${module}" "source"; fi
done done
##################### #####################
@ -340,14 +332,9 @@ done
# #
# do we have BSD sed # do we have BSD sed
if ! sed '1ia' </dev/null 2>/dev/null; then sed '1ia' </dev/null 2>/dev/null || printf "${ORANGE}Warning: You may run on a BSD style system without gnu utils ...${NN}"
printf "${ORANGE}Warning: You may run on a BSD style system without gnu utils ...${NN}"
fi
#jsonDB is now mandatory #jsonDB is now mandatory
if ! _is_function jssh_newDB ; then _is_function jssh_newDB || printf "${RED}ERROR: Mandatory module jsonDB is missing or not readable!${NN}" && exit 6
printf "${RED}ERROR: Mandatory module jsonDB is missing or not readable!${NN}"
exit 6
fi
# $1 URL, $2 filename in DATADIR # $1 URL, $2 filename in DATADIR