diff --git a/lib/functions.sh b/lib/functions.sh index 6c81d7b..bceb34a 100755 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -119,9 +119,13 @@ fixPermissions() { source lib/monitoring.sh -fail_and_report() { +report_error() { log ERROR "$2" hc_send $1 "$2" +} + +fail_and_report() { + report_error $@ exit $1 } diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index 7212d13..636c585 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -43,12 +43,13 @@ for DIR in /etc/bridgehead $(pwd); do old_git_hash="$(git -C $DIR rev-parse --verify HEAD)" if [ -z "$HTTP_PROXY_URL" ]; then log "INFO" "Git is using no proxy!" - git -C $DIR fetch 2>&1 - git -C $DIR pull 2>&1 + OUT=$(git -C $DIR fetch 2>&1 && git -C $DIR pull 2>&1) else log "INFO" "Git is using proxy ${HTTP_PROXY_URL} from ${CONFFILE}" - git -c http.proxy=$HTTP_PROXY_URL -c https.proxy=$HTTPS_PROXY_URL -C $DIR fetch 2>&1 - git -c http.proxy=$HTTP_PROXY_URL -c https.proxy=$HTTPS_PROXY_URL -C $DIR pull 2>&1 + OUT=$(git -c http.proxy=$HTTP_PROXY_URL -c https.proxy=$HTTPS_PROXY_URL -C $DIR fetch 2>&1 && git -c http.proxy=$HTTP_PROXY_URL -c https.proxy=$HTTPS_PROXY_URL -C $DIR pull 2>&1) + fi + if [ $? -ne 0 ]; then + report_error 1 "Unable to update git $DIR: $OUT" fi new_git_hash="$(git -C $DIR rev-parse --verify HEAD)" if [ "$old_git_hash" != "$new_git_hash" ]; then