Fixed naming

Update the git config repo
This commit is contained in:
Patrick Skowronek
2022-05-11 10:30:18 +02:00
parent 4c5eb05d26
commit 1928713b9d
9 changed files with 52 additions and 51 deletions

View File

@ -1,34 +1,35 @@
#!/bin/bash
service="bridgehead"
source lib/functions.sh
#checkRequirements // not required for mere update
log "INFO" "Checking for updates of services"
log "INFO" "Checking for updates of $service"
# check prerequisites
# Check git updates
for DIR in /etc/bridgehead $(pwd); do
old_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
git -C $DIR fetch 2>&1
git -C $DIR pull 2>&1
new_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
git_updated="false"
if [ "$old_git_hash" != "$new_git_hash" ]; then
log "INFO" "Pulled new changes from origin"
git_updated="true"
fi
done
# check if updates are available
old_git_hash="$(git rev-parse --verify HEAD)"
git fetch 2>&1
git pull 2>&1
new_git_hash="$(git rev-parse --verify HEAD)"
git_updated="false"
if [ "$old_git_hash" != "$new_git_hash" ]; then
log "INFO" "Pulled new changes from origin"
git_updated="true"
fi
# Check docker updates
docker_updated="false"
for image in $(docker ps --filter "name=$service" --format {{.Image}}); do
log "INFO" "Checking for Updates of Image: $image"
if docker pull $image | grep "Downloaded newer image"; then
log "INFO" "$image updated."
for IMAGE in $(docker ps --filter "name=bridgehead" --format {{.Image}}); do
log "INFO" "Checking for Updates of Image: $IMAGE"
if docker pull $IMAGE | grep "Downloaded newer image"; then
log "INFO" "$IMAGE updated."
docker_updated="true"
fi
done
# If anything is updated, restart service
if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then
log "INFO" "Due to previous updates now restarting $service@$1"
systemctl restart "$service@$1.service"
log "INFO" "Due to previous updates now restarting bridgehead"
systemctl restart 'bridgehead@*'
fi
log "INFO" "checking updates finished"
exit 0
exit 0