UpdateController/update_psa_impl

83 lines
2.6 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
if [ "$MAINTENANCE" = "NO" ]; then
log_info "update_psa:${LINENO}: MAINTENANCE OFF. Checking for updates..."
# someone must have activated the WAIT-button in ISMAS.
# Request the status of this button in updates_available().
if ! updates_available; then
update_psa_false_alarm "update requested, but no WAIT state detected !!!"
log_fatal "update_psa:${LINENO}: update requested, but no WAIT state detected !!!"
fi
else
# simulate an activated WAIT-button
set_updates_available
while :
do
sleep 5
updates_available && break
done
fi
2022-06-02 16:06:17 +02:00
log_debug "$func:${LINENO}: fetch/merge updates..."
# Fetch new updates (using git). but only when repository has already been
# cloned.
if [ $GIT_CLONE_EXECUTED -eq 0 ]; then
if ! fetch_customer_updates; then
log_error "$func:${LINENO}: fetch no data for $customer_id"\
"-> no files to update -> no psa update"
update_psa_false_alarm \
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
# TODO
fi
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
}