Report git errors

This commit is contained in:
Martin Lablans 2022-11-04 15:26:27 +01:00
parent ab3a5790de
commit 9b3acb4899
2 changed files with 10 additions and 5 deletions

View File

@ -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
}

View File

@ -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