#! /bin/bash - # Implementing update functionality for an PSA. ############################################################################### # # UPDATE PSA # Usage: # update_psa [ --? ] # [ -m ] # [ --help ] # [ --wdir "working_directory" ] # [ --file "config_file" ] # [ --dbg ] # [ --version ] # # ./update_psa --file $PWD/update_psa.conf --wdir $PWD # ############################################################################### # if [ $# -eq 0 ]; then # no parameters given -> nothing to do # exit 0 #fi if [ -z $IFS ]; then IFS=$'\n' fi MAINTENANCE="NO" # parse commandline parameters while test $# -gt 0; do case $1 in --maintenance | -m ) shift MAINTENANCE="YES" ;; --file | --fil | --fi | --f | -file | -fil | -fi | -f ) shift CONFIGFILENAME="$1" ;; --zone | --zon | --zo | --z | -zone | -zon | -zo | -z ) shift ZONE="$1" ;; --wdir | --wdi | --wd | --w | -wdir | -wdi | -wd | -w ) shift WORKING_DIRECTORY="$1" ;; --help | -hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' ) usage_and_exit 0 ;; --version | --versio | --versi | --vers | --ver | --ve | --v | \ -version | -versio | -versi | -vers | -ver | -ve | -v ) version exit 0 ;; --dbg | --db | --d | -dbg | -db | -d ) shift set_dbg_level $DEBUG ;; -*) error "Unrecognized option: $1" ;; *) break ;; esac shift done 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 fi exit -1 ###############################################################################