81 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
			Executable File
		
	
	
	
	
# !/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
 | 
						|
 | 
						|
    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
 | 
						|
 | 
						|
    log_debug "$func:${LINENO}: fetch/merge updates..."
 | 
						|
   
 | 
						|
    # Fetch new updates (using git). but only when repository has already been
 | 
						|
    # cloned.
 | 
						|
    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
 | 
						|
            
 | 
						|
    update_psa_pull_customer_repository # message to ISMAS
 | 
						|
}
 | 
						|
 |