UpdateController/update_psa_impl

93 lines
3.1 KiB
Plaintext
Raw Normal View History

2022-06-02 16:06:17 +02:00
# !/bin/bash -
source ./general_utils
source ./log_helpers
source ./git_helpers
source ./update_psa_helpers
source ./read_config
2022-06-03 21:49:16 +02:00
source ./news_to_ismas
source ./news_from_ismas
2022-06-02 16:06:17 +02:00
trap collect_current_configuration EXIT
collect_current_configuration () {
local func="${FUNCNAME[0]}"
$FATAL_FAILURE && return 1
2022-06-02 16:04:25 +02:00
# TODO: eventuell muss die version neu berechnet werden
2022-06-02 17:40:31 +02:00
current_settings_to_ismas
#for line in $(cat $PSA_UPDATE_CONF |\
2022-06-03 18:09:16 +02:00
# jq -r .conf.szeged.zg[$ZONE_GROUP].z[$ZONE].etc.psa_config)
2022-06-02 17:40:31 +02:00
#do
# conf_file="$(echo $line |
# sed -E -ne 's/^[^{}]\s+\"(DC2C_[[:alnum:]]+)\".*$/\1/gp')"
# if ! [ -z $conf_file ]; then
# local v=$(cat "$psa_config_dir/${conf_file}.json" | jq -r .version)
# echo "$conf_file.json version=$v"
# fi
#done
}
update_psa() {
2022-06-04 21:47:52 +02:00
update_psa_activated # message to ISMAS
2022-06-02 16:06:17 +02:00
local func="${FUNCNAME[0]}"
check_default_route
check_route_to_repository "185.191.219.134" # git.mimbach.de
# even for a git clone a running APISM is needed
check_for_running_apism
# an initial clone of the customer-repository (e.g. customer_281) is
# always possible, even without a ISMAS-WAIT-button
clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}
check_sanity_of_repository
$INITIAL_CLONE && return 0
local ismas_requests=0
if [ "$MAINTENANCE" = "NO" ]; then
log_info "${func}:${LINENO}: MAINTENANCE OFF. Checking for updates..."
# someone must have activated the WAIT-button in ISMAS.
# Request the status of this button in updates_available().
while [ $ismas_requests -le 3 ]; do
ismas_requests=$(( $ismas_requests + 1 ))
updates_available && break
update_psa_false_alarm "update requested, but no WAIT state detected <$ismas_requests>"
done
if [ $ismas_requests -gt 3 ]; then
log_fatal "update_psa:${LINENO}: update requested, but no WAIT state detected !!!"
fi
else
log_info "${func}:${LINENO}: MAINTENANCE ON. Emulate ISMAS updates..."
# simulate an activated WAIT-button in ISMAS
set_updates_available
while [ $ismas_requests -le 10 ]; do
sleep 5
updates_available && break
ismas_requests=$(( $ismas_requests + 1 ))
log_info "${func}:${LINENO}: updates_requested <$ismas_requests>"
done
if [ $ismas_requests -gt 10 ]; then
log_fatal "${func}:${LINENO}: NO ISMAS UPDATES AVAILABLE"
fi
fi
2022-06-02 16:06:17 +02:00
log_debug "$func:${LINENO}: before fetch/merge updates..."
2022-06-02 16:06:17 +02:00
# Fetch new updates (using git). but only when repository has already been
# cloned.
2023-05-30 16:42:03 +02:00
if ! fetch_customer_updates; then
update_psa_false_alarm \
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
log_fatal "$func:${LINENO}: fetch no data for $customer_id"\
"-> no files to update -> no psa update"
else
log_debug "$func:${LINENO}: after successful fetch_customer_repository..."
fi
2022-06-04 21:47:52 +02:00
update_psa_pull_customer_repository # message to ISMAS
2022-06-02 16:06:17 +02:00
}