From bab155e752edf5304569bf30f6abb365615130c1 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Tue, 16 Jul 2019 16:08:47 +0200 Subject: [PATCH] pdksh hack for sourcing include files --- opt/hc/bin/check_health.sh | 55 ++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/opt/hc/bin/check_health.sh b/opt/hc/bin/check_health.sh index 41d8c8d..6df0e0c 100755 --- a/opt/hc/bin/check_health.sh +++ b/opt/hc/bin/check_health.sh @@ -38,7 +38,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2019-06-18" +typeset -r SCRIPT_VERSION="2019-07-16" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files @@ -244,20 +244,47 @@ then print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_core(.sh) is not present (tip: run --fix-symlinks)" exit 1 fi -# include include_* -find ${FPATH_PARENT}/core -name "include_*.sh" -type f -print 2>/dev/null | while read INCLUDE_FILE -do - if [[ -h ${INCLUDE_FILE%%.sh} ]] - then + +# PDKSH hack (IS_PDKSH is not yet set here) +case "${KSH_VERSION}" in + *MIRBSD*|*PD*|*LEGACY*) # shellcheck source=/dev/null - (( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${INCLUDE_FILE}" - # shellcheck source=/dev/null - . ${INCLUDE_FILE} - else - print -u2 "ERROR: library file ${INCLUDE_FILE} exists but has no symlink. Run --fix-symlinks" - exit 1 - fi -done + . ${FPATH_PARENT}/core/include_core.sh + if [[ -r ${FPATH_PARENT}/core/include_data.sh && -h ${FPATH_PARENT}/core/include_data ]] + then + # shellcheck source=/dev/null + (( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${FPATH_PARENT}/core/include_data.sh" + . ${FPATH_PARENT}/core/include_data.sh + else + print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_data.sh is not present (tip: run --fix-symlinks)" + exit 1 + fi + if [[ -r ${FPATH_PARENT}/core/include_os.sh && -h ${FPATH_PARENT}/core/include_os ]] + then + # shellcheck source=/dev/null + (( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${FPATH_PARENT}/core/include_os.sh" + . ${FPATH_PARENT}/core/include_os.sh + else + print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_os.sh is not present (tip: run --fix-symlinks)" + exit 1 + fi + ;; + *) + # include include_* + find ${FPATH_PARENT}/core -name "include_*.sh" -type f -print 2>/dev/null | while read INCLUDE_FILE + do + if [[ -h ${INCLUDE_FILE%%.sh} ]] + then + # shellcheck source=/dev/null + (( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${INCLUDE_FILE}" + # shellcheck source=/dev/null + . ${INCLUDE_FILE} + else + print -u2 "ERROR: library file ${INCLUDE_FILE} exists but has no symlink. Run --fix-symlinks" + exit 1 + fi + done +esac # check for core directories [[ -d ${ARCHIVE_DIR} ]] || mkdir -p "${ARCHIVE_DIR}" >/dev/null 2>&1