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

Merge branch '6709-check-empty-hostname' into 'master'

check inc_getconfig.sh exists and hostname -f

See merge request !27
parents 6434a539 c1d2a7af
No related branches found
No related tags found
1 merge request!27check inc_getconfig.sh exists and hostname -f
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment