diff --git a/update_psa b/update_psa index 4d8c014..d94e477 100755 --- a/update_psa +++ b/update_psa @@ -25,6 +25,7 @@ if [ -z $IFS ]; then fi MAINTENANCE="NO" +WORKING_DIRECTORY=${PWD} # parse commandline parameters while test $# -gt 0; do @@ -66,42 +67,46 @@ while test $# -gt 0; do esac shift done + +source ./update_psa_impl -if cd "$WORKING_DIRECTORY"; then - source ./update_psa_impl - - if read_config - then - check_default_route - check_route_to_repository "185.191.219.134" # git.mimbach.de - check_for_running_apism - if clone_customer_repository ${CUSTOMER_REPOSITORY_PATH} - then - check_sanity_of_repository - - 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 - # updates available - update_psa - fi - fi - exit 0 +if [ -z "$WORKING_DIRECTORY" ]; then + log_fatal "update_psa:${LINENO}: empty WORKING_DIRECTORY" fi -exit -1 +if ! cd "$WORKING_DIRECTORY"; then + log_fatal "update_psa:${LINENO}: cannot cd to $WORKING_DIRECTORY" +fi + +log_info "update_psa:${LINENO}: cd to $WORKING_DIRECTORY" + +if read_config; then + check_default_route + check_route_to_repository "185.191.219.134" # git.mimbach.de + check_for_running_apism + if clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}; then + check_sanity_of_repository + + 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 + # updates available + update_psa + fi +fi +exit 0 ###############################################################################