check_for_apism, check_default_route and check_for_route_to_repository

exit the script if condition is not fulfilled.
This commit is contained in:
Gerhard Hoffmann 2022-06-25 15:19:43 +02:00
parent fc1c2221b1
commit 95a9307631

View File

@ -379,38 +379,28 @@ check_for_apism () {
APISM_RUNNING=1 APISM_RUNNING=1
log_debug "$func:${LINENO}: APISM running..." log_debug "$func:${LINENO}: APISM running..."
return 0 return 0
else
log_crit "$func:${LINENO}: *************************"
log_crit "$func:${LINENO}: !!! APISM NOT RUNNING !!!"
log_crit "$func:${LINENO}: *************************"
fi fi
return 1 log_fatal "$func:${LINENO}: !!! APISM NOT RUNNING !!!"
} }
check_default_route () { check_default_route () {
local func="${FUNCNAME[0]}"
if ip route | head -n 1 | grep -q '^default' if ip route | head -n 1 | grep -q '^default'
log_debug "$func:${LINENO}: default route set" log_debug "$func:${LINENO}: default route set"
return 0 return 0
then
log_crit "$func:${LINENO}: ***************************************"
log_crit "$func:${LINENO}: !!! NO DEFAULT ROUTE SET !!! Exiting..."
log_crit "$func:${LINENO}: ***************************************"
exit 1
fi fi
log_fatal "$func:${LINENO}: !!! NO DEFAULT ROUTE SET !!!"
} }
check_route_to_repository () { check_route_to_repository () {
local func="${FUNCNAME[0]}"
# ip_address=$1, e.g. git.mimbach.de (185.191.219.134) # ip_address=$1, e.g. git.mimbach.de (185.191.219.134)
# 185.191.219.134 via 192.168.5.254 ... # 185.191.219.134 via 192.168.5.254 ...
if test "$#" -eq 1 && ip route get "$1" | head -n 1 | grep -q "^$1" if test "$#" -eq 1 && ip route get "$1" | head -n 1 | grep -q "^$1"
log_debug "$func:${LINENO}: route to repository available" log_debug "$func:${LINENO}: route to repository available"
return 0 return 0
then
log_crit "$func:${LINENO}: ***************************************"
log_crit "$func:${LINENO}: !!! NO ROUTE TO REPO SET !!! Exiting..."
log_crit "$func:${LINENO}: ***************************************"
exit 1
fi fi
log_fatal "$func:${LINENO}: !!! NO ROUTE TO REPO SET !!!"
} }
get_customer_id () { get_customer_id () {