* Replaced 'which' by 'command -v'
* Added --list-include + added version placeholders to all include_* files * Some other fixes
This commit is contained in:
@@ -23,6 +23,20 @@
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: version_include_core()
|
||||
# DOES: dummy function for version placeholder
|
||||
# EXPECTS: n/a
|
||||
# RETURNS: 0
|
||||
function version_include_core
|
||||
{
|
||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: archive_hc()
|
||||
# DOES: archive log entries for a given HC
|
||||
@@ -1425,7 +1439,6 @@ return ${CRON_COUNT}
|
||||
function list_core
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset FACTION="${1}"
|
||||
typeset FCONFIG=""
|
||||
typeset FDIR=""
|
||||
typeset FNAME=""
|
||||
@@ -1435,17 +1448,14 @@ typeset FSTATE="enabled" # default
|
||||
typeset FFILE=""
|
||||
typeset FSCRIPT=""
|
||||
typeset HAS_FCONFIG=0
|
||||
typeset HC_VERSION=""
|
||||
|
||||
# print header
|
||||
if [[ "${FACTION}" != "list" ]]
|
||||
then
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-30s\t%-8s\t%s\t\t%s\n" "Core plugin" "State" "Version" "Config?"
|
||||
# shellcheck disable=SC2183,SC1117
|
||||
printf "%80s\n" | tr ' ' -
|
||||
fi
|
||||
print "${FPATH}" | tr ':' '\n' | grep "core$" | sort 2>/dev/null | while read -r FDIR
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-30s\t%-8s\t%s\t\t%s\n" "Core plugin" "State" "Version" "Config?"
|
||||
# shellcheck disable=SC2183,SC1117
|
||||
printf "%80s\n" | tr ' ' -
|
||||
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" | sort 2>/dev/null | while read -r FDIR
|
||||
do
|
||||
# exclude core helper librar(y|ies)
|
||||
# shellcheck disable=SC2010
|
||||
@@ -1489,28 +1499,25 @@ do
|
||||
done
|
||||
|
||||
# dead link detection
|
||||
if [[ "${FACTION}" != "list" ]]
|
||||
then
|
||||
print
|
||||
print -n "Dead links: "
|
||||
print "${FPATH}" | tr ':' '\n' | grep "core$" | while read -r FDIR
|
||||
print
|
||||
print -n "Dead links: "
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
||||
do
|
||||
# do not use 'find -type l' here!
|
||||
# shellcheck disable=SC2010,SC1117
|
||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||
do
|
||||
# do not use 'find -type l' here!
|
||||
# shellcheck disable=SC2010,SC1117
|
||||
ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FFILE
|
||||
do
|
||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||
then
|
||||
printf "%s " ${FFILE##*/}
|
||||
fi
|
||||
done
|
||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||
then
|
||||
printf "%s " ${FFILE##*/}
|
||||
fi
|
||||
done
|
||||
print
|
||||
done
|
||||
print
|
||||
|
||||
# show FPATH
|
||||
print
|
||||
print "current FPATH: ${FPATH}"
|
||||
fi
|
||||
# show FPATH
|
||||
print
|
||||
print "current FPATH: ${FPATH}"
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -1539,7 +1546,6 @@ typeset FSCRIPT=""
|
||||
typeset HAS_FCONFIG=0
|
||||
typeset HAS_FHEALTHY=""
|
||||
typeset DISABLE_FFILE=""
|
||||
typeset HC_VERSION=""
|
||||
|
||||
# build search needle
|
||||
if [[ -z "${ARG_LIST}" ]]
|
||||
@@ -1663,11 +1669,11 @@ if [[ "${FACTION}" != "list" ]]
|
||||
then
|
||||
print
|
||||
print -n "Dead links: "
|
||||
print "${FPATH}" | tr ':' '\n' | grep -v "core" | while read -r FDIR
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core" 2>/dev/null | while read -r FDIR
|
||||
do
|
||||
# do not use 'find -type l' here!
|
||||
# shellcheck disable=SC2010,SC1117
|
||||
ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FFILE
|
||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||
do
|
||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||
then
|
||||
@@ -1694,6 +1700,88 @@ fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: list_include()
|
||||
# DOES: find HC include files (libraries)
|
||||
# EXPECTS: n/a
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function list_include
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset FDIR=""
|
||||
typeset FNAME=""
|
||||
typeset FVERSION=""
|
||||
typeset FFILE=""
|
||||
typeset FSTATE="enabled" # default
|
||||
typeset FSCRIPT=""
|
||||
typeset FFUNCTIONS=""
|
||||
typeset FFUNCTION=""
|
||||
|
||||
# print header
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-20s\t%-8s\t%12s\t\t%s\n" "Include/libary" "State" "Version" "Functions"
|
||||
# shellcheck disable=SC2183,SC1117
|
||||
printf "%100s\n" | tr ' ' -
|
||||
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | sort 2>/dev/null | while read -r FDIR
|
||||
do
|
||||
# exclude core helper librar(y|ies)
|
||||
# shellcheck disable=SC2010
|
||||
ls -1 ${FDIR}/*.sh 2>/dev/null | grep "include_" 2>/dev/null | sort 2>/dev/null | while read -r FFILE
|
||||
do
|
||||
# cache script contents in memory
|
||||
FSCRIPT=$(<${FFILE})
|
||||
|
||||
# find function name
|
||||
FNAME=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]].*version_" 2>/dev/null)
|
||||
# look for version string (cut off comments but don't use [:space:] in tr)
|
||||
FVERSION=$(print -R "${FSCRIPT}" | grep '^typeset _VERSION=' 2>/dev/null |\
|
||||
awk 'match($0,/[0-9]+-[0-9]+-[0-9]+/){print substr($0, RSTART, RLENGTH)}' 2>/dev/null)
|
||||
|
||||
# get list of functions
|
||||
FFUNCTIONS=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]]+" 2>/dev/null | awk '{ print $2}' 2>/dev/null)
|
||||
|
||||
# check state (only for unlinked)
|
||||
[[ -h ${FFILE%%.*} ]] || FSTATE="unlinked"
|
||||
|
||||
# show results
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-20s\t%-8s\t%12s\n" \
|
||||
"${FNAME#function version_*}" \
|
||||
"${FSTATE}" \
|
||||
"${FVERSION#typeset _VERSION=*}"
|
||||
print "${FFUNCTIONS}" | while read -r FFUNCTION
|
||||
do
|
||||
printf "%64s%s\n" "" "${FFUNCTION}"
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# dead link detection
|
||||
print
|
||||
print -n "Dead links: "
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
||||
do
|
||||
# do not use 'find -type l' here!
|
||||
# shellcheck disable=SC2010,SC1117
|
||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||
do
|
||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||
then
|
||||
printf "%s " ${FFILE##*/}
|
||||
fi
|
||||
done
|
||||
done
|
||||
print
|
||||
|
||||
# show FPATH
|
||||
print
|
||||
print "current FPATH: ${FPATH}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: log()
|
||||
# DOES: handle messages
|
||||
|
||||
@@ -23,6 +23,20 @@
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: version_include_core()
|
||||
# DOES: dummy function for version placeholder
|
||||
# EXPECTS: n/a
|
||||
# RETURNS: 0
|
||||
function version_include_data
|
||||
{
|
||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_get_lvalue_from_config()
|
||||
# DOES: get an lvalue from the configuration file
|
||||
|
||||
@@ -23,6 +23,20 @@
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: version_include_core()
|
||||
# DOES: dummy function for version placeholder
|
||||
# EXPECTS: n/a
|
||||
# RETURNS: 0
|
||||
function version_include_os
|
||||
{
|
||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_get_distro()
|
||||
# DOES: get Linux distribution name & version, sets $LINUX_DISTRO & $LINUX_RELEASE
|
||||
@@ -128,7 +142,7 @@ check_platform 'Linux' || {
|
||||
return 1
|
||||
}
|
||||
|
||||
_CRM_BIN="$(which crm 2>/dev/null)"
|
||||
_CRM_BIN="$(command -v crm 2>/dev/null)"
|
||||
if [[ -x ${_CRM_BIN} && -n "${_CRM_BIN}" ]]
|
||||
then
|
||||
# check for active
|
||||
@@ -164,7 +178,7 @@ check_platform 'Linux' || {
|
||||
return 1
|
||||
}
|
||||
|
||||
_DOCKER_BIN="$(which docker 2>/dev/null)"
|
||||
_DOCKER_BIN="$(command -v docker 2>/dev/null)"
|
||||
if [[ -x ${_DOCKER_BIN} && -n "${_DOCKER_BIN}" ]]
|
||||
then
|
||||
# check for active
|
||||
@@ -200,7 +214,7 @@ check_platform 'Linux' || {
|
||||
return 1
|
||||
}
|
||||
|
||||
_NMCLI_BIN="$(which nmcli 2>/dev/null)"
|
||||
_NMCLI_BIN="$(command -v nmcli 2>/dev/null)"
|
||||
if [[ -x ${_NMCLI_BIN} && -n "${_NMCLI_BIN}" ]]
|
||||
then
|
||||
# check for active
|
||||
|
||||
@@ -80,13 +80,13 @@ _HC_STDERR_LOG_SHORT="${HC_STDERR_LOG##*/}"
|
||||
case "${OS_NAME}" in
|
||||
"Linux")
|
||||
# prefer mutt :-)
|
||||
_MUTT_BIN="$(which mutt 2>/dev/null)"
|
||||
_MUTT_BIN="$(command -v mutt 2>/dev/null)"
|
||||
if [[ -x ${_MUTT_BIN} ]] && [[ -n "${_MUTT_BIN}" ]]
|
||||
then
|
||||
_MAIL_METHOD="mutt"
|
||||
else
|
||||
# prefer mailx next
|
||||
_MAILX_BIN="$(which mailx 2>/dev/null)"
|
||||
_MAILX_BIN="$(command -v mailx 2>/dev/null)"
|
||||
if [[ -x ${_MAILX_BIN} ]] && [[ -n "${_MAILX_BIN}" ]]
|
||||
then
|
||||
_MAIL_METHOD="mailx"
|
||||
@@ -103,13 +103,13 @@ esac
|
||||
if [[ "${_MAIL_METHOD}" = "sendmail" ]]
|
||||
then
|
||||
# find 'sendmail'
|
||||
_SENDMAIL_BIN="$(which sendmail 2>/dev/null)"
|
||||
_SENDMAIL_BIN="$(command -v sendmail 2>/dev/null)"
|
||||
if [[ ! -x ${_SENDMAIL_BIN} ]] || [[ -z "${_SENDMAIL_BIN}" ]]
|
||||
then
|
||||
die "unable to send e-mail - sendmail is not installed here"
|
||||
fi
|
||||
# find 'uuencode'
|
||||
_UUENCODE_BIN="$(which uuencode 2>/dev/null)"
|
||||
_UUENCODE_BIN="$(command -v uuencode 2>/dev/null)"
|
||||
if [[ ! -x ${_UUENCODE_BIN} ]] || [[ -z "${_UUENCODE_BIN}" ]]
|
||||
then
|
||||
die "unable to send e-mail - uuencode is not installed here"
|
||||
|
||||
@@ -100,7 +100,7 @@ case "${ARG_SMS_PROVIDER}" in
|
||||
*kapow*|*KAPOW*|*Kapow*)
|
||||
# KAPOW (https://www.kapow.co.uk/)
|
||||
# find 'curl'
|
||||
_CURL_BIN="$(which curl 2>/dev/null)"
|
||||
_CURL_BIN="$(command -v curl 2>/dev/null)"
|
||||
if [[ -x ${_CURL_BIN} ]] && [[ -n "${_CURL_BIN}" ]]
|
||||
then
|
||||
_SMS_TEXT=$(print "${_FROM_MSG}: HC ${_SMS_HC} failed, FAIL_ID=${_SMS_FAIL_ID}" | data_encode_url)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
function report_std
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2019-03-18" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user