Skip to content
Snippets Groups Projects
Commit c1d2a7af authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check inc_getconfig.sh exists and hostname -f

parent 6434a539
Branches
No related tags found
1 merge request!27check inc_getconfig.sh exists and hostname -f
...@@ -20,8 +20,11 @@ ...@@ -20,8 +20,11 @@
# 2023-01-22 v0.4 ah fix _bStopOnError; some shellfixes # 2023-01-22 v0.4 ah fix _bStopOnError; some shellfixes
# 2023-02-17 v0.5 ah add hostnamme into CFGSTORAGE # 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.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 tmpfile=/tmp/outcurl.tmp
tmpfile2=/tmp/outcurl2.tmp tmpfile2=/tmp/outcurl2.tmp
...@@ -768,7 +771,7 @@ ENDOFHELP ...@@ -768,7 +771,7 @@ ENDOFHELP
# ------------------------------------------------------------ # ------------------------------------------------------------
echo echo
echo "##### DIRECTOR HELPER $MY_NAME - $MY_IP" echo "##### DIRECTOR HELPER v$_version ##### $MY_NAME $MY_IP"
echo echo
if [ "$1" = "--cfg" ] && [ -n "$2" ]; then if [ "$1" = "--cfg" ] && [ -n "$2" ]; then
...@@ -776,7 +779,12 @@ if [ "$1" = "--cfg" ] && [ -n "$2" ]; then ...@@ -776,7 +779,12 @@ if [ "$1" = "--cfg" ] && [ -n "$2" ]; then
. "${2}" . "${2}"
shift 2 shift 2
else 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 fi
. $(dirname $0)/inc_functions.sh . $(dirname $0)/inc_functions.sh
. $(dirname $0)/inc/rest-api-client.sh . $(dirname $0)/inc/rest-api-client.sh
...@@ -791,6 +799,10 @@ cd $(dirname $0) || exit ...@@ -791,6 +799,10 @@ cd $(dirname $0) || exit
ls ./$(basename $0) >/dev/null || exit 1 ls ./$(basename $0) >/dev/null || exit 1
_initVars _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 # ensure that ./inc_getconfig.sh was loaded
if [ -z "${dir_cfg}" ]; then if [ -z "${dir_cfg}" ]; then
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# - curl # - curl
# - jq # - jq
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# ah = axel.hahn@iml.unibe.ch # ah = axel.hahn@unibe.ch
# 2021-03-.. init # 2021-03-.. init
# 2022-01-11 v0.7 ah shellcheck # 2022-01-11 v0.7 ah shellcheck
# 2022-02-16 v0.8 ah add --cfg param # 2022-02-16 v0.8 ah add --cfg param
...@@ -18,20 +18,25 @@ ...@@ -18,20 +18,25 @@
# 2022-07-08 v0.11 ah check pipes in output and performance data # 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-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-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" _product="ICINGA PASSIVE CLIENT"
_version="0.14" _version="0.15"
_license="GNU GPL 3.0" _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 typeset -i debug=0
# source config ... # 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 # where to find check scripts ... first directory wins
...@@ -43,6 +48,10 @@ logfile="${dir_logs}/execution.log" ...@@ -43,6 +48,10 @@ logfile="${dir_logs}/execution.log"
ch="$( dirname $0 )/inc/confighandler.sh" ch="$( dirname $0 )/inc/confighandler.sh"
MY_NAME=$(hostname -f) 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 # for loop mode only: max. random sleep time
typeset -i sleeptime=30 typeset -i sleeptime=30
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment