From f9db229bd53d58ac22e90d5a9880921296859d0c Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Tue, 5 Feb 2019 14:07:29 +0100 Subject: [PATCH] Better exit codes + fix for cleanup --- sources/bin/check_health.sh | 7 ++++--- sources/lib/platform/linux/check_linux_fs_usage.sh | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sources/bin/check_health.sh b/sources/bin/check_health.sh index 510a681..7e5c3d9 100644 --- a/sources/bin/check_health.sh +++ b/sources/bin/check_health.sh @@ -27,6 +27,7 @@ # + include functions # For other pre-requisites see the documentation in display_usage() # REQUIRES (OPTIONAL): display_*(), notify_*(), report_*() +# EXISTS: 0=no errors encountered, >0=some errors encountered # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2019-01-24" +typeset -r SCRIPT_VERSION="2019-01-31" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files @@ -1172,7 +1173,7 @@ case ${ARG_ACTION} in display_init "${HC_RUN}" "" "MISSING" else warn "cannot find HC: ${HC_RUN}" - EXIT_CODE=${RUN_RC} + EXIT_CODE=1 fi continue fi @@ -1185,7 +1186,7 @@ case ${ARG_ACTION} in display_init "${HC_RUN}" "" "DISABLED" else warn "may not run disabled HC: ${HC_RUN}" - EXIT_CODE=${RUN_RC} + EXIT_CODE=0 fi continue fi diff --git a/sources/lib/platform/linux/check_linux_fs_usage.sh b/sources/lib/platform/linux/check_linux_fs_usage.sh index fb53ebb..2605bcb 100644 --- a/sources/lib/platform/linux/check_linux_fs_usage.sh +++ b/sources/lib/platform/linux/check_linux_fs_usage.sh @@ -24,8 +24,9 @@ # @(#) HISTORY: # @(#) 2019-01-24: initial version [Patrick Van der Veken] # @(#) 2019-01-27: regex fix [Patrick Van der Veken] -# @(#) 2019-01-30: refactored to support custom defintions with all +# @(#) 2019-01-30: refactored to support custom definitions with all # filesystems check [Patrick Van der Veken] +# @(#) 2019-02-04: fix in cleanup # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_linux_fs_usage { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-30" # YYYY-MM-DD +typeset _VERSION="2019-02-04" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -64,7 +65,7 @@ typeset _SPACE_FILE="${TMP_DIR}/.$0.space.$$" # set local trap for cleanup # shellcheck disable=SC2064 -trap "rm -f ${_SPACE_FILE}.* ${_INODES_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 +trap "rm -f ${_SPACE_FILE} ${_INODES_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -303,7 +304,7 @@ then fi # do cleanup -rm -f ${_INODES_FILE}.* ${_SPACE_FILE}.* >/dev/null 2>&1 +rm -f ${_INODES_FILE} ${_SPACE_FILE} >/dev/null 2>&1 return 0 }