From f72a185dbba6cdd618f3e3e065b805d32e1b5555 Mon Sep 17 00:00:00 2001 From: Martin Lablans Date: Mon, 17 Oct 2022 16:07:25 +0200 Subject: [PATCH] Be more specific about what changed on an update --- lib/update-bridgehead.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index ef07590..eefa38a 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -19,6 +19,8 @@ checkOwner /etc/bridgehead bridgehead || fail_and_report 1 "Update failed: Wrong CREDHELPER="/srv/docker/bridgehead/lib/gitpassword.sh" +CHANGES="" + # Check git updates for DIR in /etc/bridgehead $(pwd); do log "INFO" "Checking for updates to git repo $DIR ..." @@ -39,7 +41,9 @@ for DIR in /etc/bridgehead $(pwd); do new_git_hash="$(git -C $DIR rev-parse --verify HEAD)" git_updated="false" if [ "$old_git_hash" != "$new_git_hash" ]; then - log "INFO" "Updated git repository in ${DIR} from commit $old_git_hash to $new_git_hash" + CHANGE="Updated git repository in ${DIR} from commit $old_git_hash to $new_git_hash" + CHANGES+="$CHANGE\n" + log "INFO" "$CHANGE" # NOTE: Link generation doesn't work on repositories placed at an self-hosted instance of bitbucket. # See: https://community.atlassian.com/t5/Bitbucket-questions/BitBucket-4-14-diff-between-any-two-commits/qaq-p/632974 git_repository_url="$(git -C $DIR remote get-url origin)" @@ -63,14 +67,16 @@ docker_updated="false" for IMAGE in $(cat $PROJECT/docker-compose.yml | grep "image:" | sed -e 's_^.*image: \(.*\).*$_\1_g; s_\"__g'); do log "INFO" "Checking for Updates of Image: $IMAGE" if docker pull $IMAGE | grep "Downloaded newer image"; then - log "INFO" "$IMAGE updated." + CHANGE="Image $IMAGE updated." + CHANGES+="$CHANGE\n" + log "INFO" "$CHANGE" docker_updated="true" fi done # If anything is updated, restart service if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then - RES="Update detected, now restarting bridgehead" + RES="Updates detected, now restarting bridgehead:\n$CHANGES" log "INFO" "$RES" hc_send log "$RES" sudo /bin/systemctl restart bridgehead@*.service