# !/bin/bash - source ./general_utils source ./log_helpers source ./git_helpers source ./update_psa_helpers source ./read_config source ./news_to_ismas source ./news_from_ismas trap collect_current_configuration EXIT collect_current_configuration () { local func="${FUNCNAME[0]}" $FATAL_FAILURE && return 1 # TODO: eventuell muss die version neu berechnet werden current_settings_to_ismas #for line in $(cat $PSA_UPDATE_CONF |\ # jq -r .conf.szeged.zg[$ZONE_GROUP].z[$ZONE].etc.psa_config) #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() { update_psa_activated # message to ISMAS 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 log_debug "$func:${LINENO}: before fetch/merge updates..." # Fetch new updates (using git). but only when repository has already been # cloned. 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 update_psa_pull_customer_repository # message to ISMAS }