diff --git a/director-cli.sh b/director-cli.sh index a46fb0ef394d7e1d51a70a391fcd0cb3e26fcf41..6bc7c5a5b8aa1f4b5c4e5dd8884eb6135e1bafe1 100755 --- a/director-cli.sh +++ b/director-cli.sh @@ -20,8 +20,11 @@ # 2023-01-22 v0.4 ah fix _bStopOnError; some shellfixes # 2023-02-17 v0.5 ah add hostnamme into CFGSTORAGE # 2023-02-17 v0.6 ah remove invalid line in cleanup +# 2023-02-17 v0.7 ah check inc_getconfig.sh exists and hostname -f has a value # ====================================================================== +_version="0.7" + tmpfile=/tmp/outcurl.tmp tmpfile2=/tmp/outcurl2.tmp @@ -768,7 +771,7 @@ ENDOFHELP # ------------------------------------------------------------ echo -echo "##### DIRECTOR HELPER $MY_NAME - $MY_IP" +echo "##### DIRECTOR HELPER v$_version ##### $MY_NAME $MY_IP" echo if [ "$1" = "--cfg" ] && [ -n "$2" ]; then @@ -776,7 +779,12 @@ if [ "$1" = "--cfg" ] && [ -n "$2" ]; then . "${2}" shift 2 else - . "$( dirname $0 )/inc_getconfig.sh" + _cfg="$( dirname $0 )/inc_getconfig.sh" + if [ ! -f "$_cfg" ]; then + echo "ERROR: The configuration file $_cfg was not created yet." + exit 1 + fi + . "$_cfg" fi . $(dirname $0)/inc_functions.sh . $(dirname $0)/inc/rest-api-client.sh @@ -791,6 +799,10 @@ cd $(dirname $0) || exit ls ./$(basename $0) >/dev/null || exit 1 _initVars +if [ -z "$MY_NAME" ]; then + echo "ERROR: hostname is empty. Ensure that the command 'hostname -f' returns a fqdn." + exit 1 +fi # ensure that ./inc_getconfig.sh was loaded if [ -z "${dir_cfg}" ]; then diff --git a/icinga-cli.sh b/icinga-cli.sh index 39865b550261b046b1bc4fa471b553e1436477ab..6c45989e7d15c74a7ab21347c77dd530a39269ca 100755 --- a/icinga-cli.sh +++ b/icinga-cli.sh @@ -9,7 +9,7 @@ # - curl # - jq # ---------------------------------------------------------------------- -# ah = axel.hahn@iml.unibe.ch +# ah = axel.hahn@unibe.ch # 2021-03-.. init # 2022-01-11 v0.7 ah shellcheck # 2022-02-16 v0.8 ah add --cfg param @@ -18,20 +18,25 @@ # 2022-07-08 v0.11 ah check pipes in output and performance data # 2023-01-30 v0.12 ah remove pipes with sed remove the pipe before performancedata # 2023-02-13 v0.13 ah rename myHost to MY_NAME (like in director_cli) -# 2023-02-17 v0.14 ah add hostnamme into CFGSTORAGE +# 2023-02-17 v0.14 ah add hostnamme into CFGSTORAGE +# 2023-02-17 v0.15 ah check inc_getconfig.sh exists and hostname -f has a value # ====================================================================== _product="ICINGA PASSIVE CLIENT" -_version="0.14" +_version="0.15" _license="GNU GPL 3.0" -_copyright='(c) 2020 Institute for Medical Education * University of Bern' +_copyright='(c) Institute for Medical Education * University of Bern' typeset -i debug=0 # source config ... -. "$( dirname $0 )/inc_getconfig.sh" - +_cfg="$( dirname $0 )/inc_getconfig.sh" +if [ ! -f "$_cfg" ]; then + echo "ERROR: The configuration file $_cfg was not created yet." + exit 1 +fi +. "$_cfg" # where to find check scripts ... first directory wins @@ -43,6 +48,10 @@ logfile="${dir_logs}/execution.log" ch="$( dirname $0 )/inc/confighandler.sh" MY_NAME=$(hostname -f) +if [ -z "$MY_NAME" ]; then + echo "ERROR: hostname is empty. Ensure that the command 'hostname -f' returns a fqdn." + exit 1 +fi # for loop mode only: max. random sleep time typeset -i sleeptime=30