diff --git a/director-cli.sh b/director-cli.sh index 1a30e7cb1f685aea071bc4e28882ad58fb7452dc..a6311bb37508e1f0260ff3d539de47f03b71b5a0 100755 --- a/director-cli.sh +++ b/director-cli.sh @@ -13,12 +13,11 @@ # - use puppet facts # - UniBe network and group names - see hostCreate() # +# ---------------------------------------------------------------------- +# ah = axel.hahn@iml.unibe.ch +# 2022-02-16 v0.2 ah add --cfg param # ====================================================================== -. `dirname $0`/inc_getconfig.sh -. `dirname $0`/inc_functions.sh -. `dirname $0`/inc/rest-api-client.sh - tmpfile=/tmp/outcurl.tmp tmpfile2=/tmp/outcurl2.tmp @@ -733,6 +732,10 @@ Director actions Other parameters + --cfg CONFIGFILE + load a costom config file; default: ./inc_getconfig.sh + This must be the 1st parameter to be processed. + --debug enable debug output. @@ -761,24 +764,33 @@ echo echo "##### DIRECTOR HELPER $MY_NAME - $MY_IP" echo +if [ "$1" = "--cfg" ] && [ -n "$2" ]; then + echo "INFO: loading custom config [$2]..." + . "${2}" + shift 2 +else + . "$( dirname $0 )/inc_getconfig.sh" +fi +. `dirname $0`/inc_functions.sh +. `dirname $0`/inc/rest-api-client.sh + + +if [ $# -eq 0 ]; then + showHelp + exit 0 +fi + cd `dirname $0` ls ./`basename $0` >/dev/null || exit 1 _initVars - # ensure that ./inc_getconfig.sh was loaded if [ -z "${dir_cfg}" ]; then echo ERROR: Client is not installed/ configured yet on this machine. exit 1 fi -if [ $# -eq 0 ]; then - showHelp - exit 0 -fi - - while [ $# -gt 0 ]; do case "$1" in diff --git a/icinga-cli.sh b/icinga-cli.sh index 3e8358330ca9bbdeb0bfc8fab5c6012d5b50bf91..7081f1216c8b9da16ef1891cdf5ac22c8fe8f970 100755 --- a/icinga-cli.sh +++ b/icinga-cli.sh @@ -12,21 +12,21 @@ # ah = axel.hahn@iml.unibe.ch # 2021-03-.. init # 2022-01-11 v0.7 ah shellcheck +# 2022-02-16 v0.8 ah add --cfg param # ====================================================================== _product="ICINGA PASSIVE CLIENT" -_version="0.7" +_version="0.8" _license="GNU GPL 3.0" _copyright='(c) 2020 Institute for Medical Education * University of Bern' typeset -i debug=0 # source config ... -. "$( dirname $0 )/inc_getconfig.sh" +# . "$( dirname $0 )/inc_getconfig.sh" + -. "$( dirname $0 )/inc_functions.sh" -. "$( dirname $0 )/inc/rest-api-client.sh" # where to find check scripts ... first directory wins # dir_plugins="/opt/imlmonitor/client/plugins/ /usr/lib64/nagios/plugins" @@ -451,13 +451,16 @@ A new local check will be added to Icinga while running it the first time. GENERAL PARAMETERS + --cfg CONFIGFILE + load a costom config file; default: ./inc_getconfig.sh + This must be the 1st parameter to be processed. + --help or -h or -? show this help and abort. --version or -v show the version abd abort - SERVICE ACTIONS --list @@ -538,6 +541,20 @@ ________________________________________________________________________________ EOBANNER +if [ "$1" = "--cfg" ] && [ -n "$2" ]; then + echo "INFO: loading custom config [$2]..." + . "${2}" + shift 2 +else + . "$( dirname $0 )/inc_getconfig.sh" +fi +. "$( dirname $0 )/inc_functions.sh" +. "$( dirname $0 )/inc/rest-api-client.sh" + +if [ $# -eq 0 ]; then + showHelp + exit 0 +fi if [ -z "${dir_cfg}" ]; then echo ERROR: $_product is not installed/ configured yet on this machine. @@ -548,10 +565,7 @@ icingaHostMustExist touch ${logfile} -if [ $# -eq 0 ]; then - showHelp - exit 0 -fi + while [ $# -gt 0 ]; do