* fix for --check-host routine
* better discovery for systemctl in include_os * other smaller fixes
This commit is contained in:
parent
dc9adb907b
commit
7b01b5871f
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
# define the version (YYYY-MM-DD)
|
# define the version (YYYY-MM-DD)
|
||||||
typeset -r SCRIPT_VERSION="2019-03-16"
|
typeset -r SCRIPT_VERSION="2019-03-22"
|
||||||
# location of parent directory containing KSH functions/HC plugins
|
# location of parent directory containing KSH functions/HC plugins
|
||||||
typeset -r FPATH_PARENT="/opt/hc/lib"
|
typeset -r FPATH_PARENT="/opt/hc/lib"
|
||||||
# location of custom HC configuration files
|
# location of custom HC configuration files
|
||||||
@ -658,7 +658,7 @@ typeset FFILE=""
|
|||||||
typeset FSYML=""
|
typeset FSYML=""
|
||||||
|
|
||||||
# find missing symlinks (do not skip core plug-ins here)
|
# find missing symlinks (do not skip core plug-ins here)
|
||||||
print "${FPATH}" | tr ':' '\n' | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
find ${FDIR} -type f -print 2>/dev/null | while read -r FFILE
|
find ${FDIR} -type f -print 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
@ -675,19 +675,18 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# find & remove broken symbolic links (do not skip core plug-ins here)
|
# find & remove broken symbolic links (do not skip core plug-ins here)
|
||||||
print "${FPATH}" | tr ':' '\n' | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# do not use 'find -type l' here!
|
# do not use 'find -type l' here!
|
||||||
# shellcheck disable=SC2010
|
# shellcheck disable=SC2010
|
||||||
ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FSYML
|
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FSYML
|
||||||
do
|
do
|
||||||
# check if file is a dead symlink
|
# check if file is a dead symlink
|
||||||
if [[ -h "${FDIR}/${FSYML}" ]] && [[ ! -f "${FDIR}/${FSYML}" ]]
|
if [[ -h "${FDIR}/${FSYML}" ]] && [[ ! -f "${FDIR}/${FSYML}" ]]
|
||||||
then
|
then
|
||||||
rm -f "${FDIR}/${FSYML}" >/dev/null
|
rm -f "${FDIR}/${FSYML}" >/dev/null
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
(( $? == 0 )) && \
|
(( $? == 0 )) && print -u2 "INFO: removed dead symbolic link ${FSYML}"
|
||||||
print -u2 "INFO: remove dead symbolic link ${FSYML}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -1137,7 +1136,8 @@ HC_LOG="${LOG_DIR}/hc.log"
|
|||||||
# act on HC check(s)
|
# act on HC check(s)
|
||||||
case ${ARG_ACTION} in
|
case ${ARG_ACTION} in
|
||||||
1) # check (status) HC(s)
|
1) # check (status) HC(s)
|
||||||
print "${ARG_HC}" | tr ',' '\n' | grep -v '^$' | while read -r HC_CHECK
|
print "${ARG_HC}" | tr ',' '\n' 2>/dev/null | grep -v '^$' 2>/dev/null |\
|
||||||
|
while read -r HC_CHECK
|
||||||
do
|
do
|
||||||
# check for HC (function)
|
# check for HC (function)
|
||||||
exists_hc "${HC_CHECK}" && die "cannot find HC: ${HC_CHECK}"
|
exists_hc "${HC_CHECK}" && die "cannot find HC: ${HC_CHECK}"
|
||||||
@ -1160,7 +1160,8 @@ case ${ARG_ACTION} in
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
2) # disable HC(s)
|
2) # disable HC(s)
|
||||||
print "${ARG_HC}" | tr ',' '\n' | grep -v '^$' | while read -r HC_DISABLE
|
print "${ARG_HC}" | tr ',' '\n' 2>/dev/null | grep -v '^$' 2>/dev/null |\
|
||||||
|
while read -r HC_DISABLE
|
||||||
do
|
do
|
||||||
# check for HC (function)
|
# check for HC (function)
|
||||||
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
||||||
@ -1177,7 +1178,8 @@ case ${ARG_ACTION} in
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
3) # enable HC(s)
|
3) # enable HC(s)
|
||||||
print "${ARG_HC}" | tr ',' '\n' | grep -v '^$' | while read -r HC_ENABLE
|
print "${ARG_HC}" | tr ',' '\n' 2>/dev/null | grep -v '^$' 2>/dev/null |\
|
||||||
|
while read -r HC_ENABLE
|
||||||
do
|
do
|
||||||
# check for HC (function)
|
# check for HC (function)
|
||||||
exists_hc "${HC_ENABLE}" && die "cannot find HC: ${HC_ENABLE}"
|
exists_hc "${HC_ENABLE}" && die "cannot find HC: ${HC_ENABLE}"
|
||||||
@ -1206,7 +1208,8 @@ case ${ARG_ACTION} in
|
|||||||
# --check-host handling
|
# --check-host handling
|
||||||
(( ARG_CHECK_HOST == 1 )) && init_check_host
|
(( ARG_CHECK_HOST == 1 )) && init_check_host
|
||||||
# execute plug-in(s)
|
# execute plug-in(s)
|
||||||
print "${ARG_HC}" | tr ',' '\n' | grep -v '^$' | while read -r HC_RUN
|
print "${ARG_HC}" | tr ',' '\n' 2>/dev/null | grep -v '^$' 2>/dev/null |\
|
||||||
|
while read -r HC_RUN
|
||||||
do
|
do
|
||||||
# re-initialize messages stash (log of failed checks)
|
# re-initialize messages stash (log of failed checks)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
@ -1287,6 +1290,13 @@ case ${ARG_ACTION} in
|
|||||||
if (( RUN_RC == 0 ))
|
if (( RUN_RC == 0 ))
|
||||||
then
|
then
|
||||||
log "executed HC: ${HC_RUN} [RC=${RUN_RC}]"
|
log "executed HC: ${HC_RUN} [RC=${RUN_RC}]"
|
||||||
|
# call for display_init with extra code 'OK' because some plugin end
|
||||||
|
# successfully *without* any entries in $HC_MSG_FILE (so handle_hc will
|
||||||
|
# never get to display_init())
|
||||||
|
if (( DO_DISPLAY_INIT == 1 )) && [[ ! -s "${HC_MSG_FILE}" ]]
|
||||||
|
then
|
||||||
|
display_init "${HC_RUN}" "" "OK"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# call for display_init with extra code 'ERROR'
|
# call for display_init with extra code 'ERROR'
|
||||||
if (( DO_DISPLAY_INIT == 1 ))
|
if (( DO_DISPLAY_INIT == 1 ))
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
function display_init
|
function display_init
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
typeset _VERSION="2019-03-22" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -76,6 +76,9 @@ fi
|
|||||||
if [[ -n "${_DISPLAY_MSG_CODE}" ]]
|
if [[ -n "${_DISPLAY_MSG_CODE}" ]]
|
||||||
then
|
then
|
||||||
case "${_DISPLAY_MSG_CODE}" in
|
case "${_DISPLAY_MSG_CODE}" in
|
||||||
|
OK|ok)
|
||||||
|
_DISPLAY_COLOR="${_GREEN}"
|
||||||
|
;;
|
||||||
ERROR|error)
|
ERROR|error)
|
||||||
_DISPLAY_COLOR="${_MAGENTA}"
|
_DISPLAY_COLOR="${_MAGENTA}"
|
||||||
;;
|
;;
|
||||||
|
@ -111,13 +111,14 @@ check_platform 'Linux' || {
|
|||||||
|
|
||||||
# default is sysv
|
# default is sysv
|
||||||
LINUX_INIT="sysv"
|
LINUX_INIT="sysv"
|
||||||
if [[ -r /usr/lib/systemd && -x /usr/bin/systemctl ]]
|
if [[ -r /usr/lib/systemd && -n "$(command -v systemctl 2>/dev/null)" ]]
|
||||||
then
|
then
|
||||||
LINUX_INIT="systemd"
|
LINUX_INIT="systemd"
|
||||||
elif [[ -r /usr/share/upstart ]]
|
elif [[ -r /usr/share/upstart ]]
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LINUX_INIT="upstart"
|
LINUX_INIT="upstart"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -218,7 +219,7 @@ _NMCLI_BIN="$(command -v nmcli 2>/dev/null)"
|
|||||||
if [[ -x ${_NMCLI_BIN} && -n "${_NMCLI_BIN}" ]]
|
if [[ -x ${_NMCLI_BIN} && -n "${_NMCLI_BIN}" ]]
|
||||||
then
|
then
|
||||||
# check for active
|
# check for active
|
||||||
_HAS_NM=$(nmcli networking 2>/dev/null | grep -c -i "enabled")
|
_HAS_NM=$(nmcli networking 2>/dev/null | grep -c -i "enabled" 2>/dev/null)
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "NetworkManager is not active here"
|
(( ARG_DEBUG > 0 )) && debug "NetworkManager is not active here"
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user