Reformated files with unix coding

This commit is contained in:
root 2021-12-22 13:18:41 +01:00
parent 2cf8fe2829
commit 4f406a96c8
2 changed files with 48 additions and 48 deletions

12
uninstall-bridgehead.sh Normal file → Executable file
View File

@ -1,6 +1,6 @@
echo "Stoping systemd services and removing bridgehead" echo "Stoping systemd services and removing bridgehead"
source site.conf source site.conf
systemctl stop bridgehead@"${project}".service systemctl stop bridgehead@"${project}".service
systemctl stop bridgehead-update@"${project}".timer systemctl stop bridgehead-update@"${project}".timer

84
update-bridgehead.sh Normal file → Executable file
View File

@ -1,42 +1,42 @@
#!/bin/bash #!/bin/bash
service="bridgehead" service="bridgehead"
# Creates logs # Creates logs
log() { log() {
echo "$(date +'%Y-%m-%d %T')" "$1:" "$2" echo "$(date +'%Y-%m-%d %T')" "$1:" "$2"
} }
log "INFO" "Checking for updates of $service" log "INFO" "Checking for updates of $service"
# check prerequisites # check prerequisites
prerequisites="git docker docker-compose" prerequisites="git docker docker-compose"
for prerequisite in $prerequisites; do for prerequisite in $prerequisites; do
$prerequisite --version 2>&1 $prerequisite --version 2>&1
is_available=$? is_available=$?
if [ $is_available -gt 0 ]; then if [ $is_available -gt 0 ]; then
log "ERROR" "Prerequisite not fulfilled - $prerequisite is not available!" log "ERROR" "Prerequisite not fulfilled - $prerequisite is not available!"
exit 79 exit 79
fi fi
done done
# check if updates are available # check if updates are available
old_git_hash="$(git rev-parse --verify HEAD)" old_git_hash="$(git rev-parse --verify HEAD)"
git fetch 2>&1 git fetch 2>&1
git pull 2>&1 git pull 2>&1
new_git_hash="$(git rev-parse --verify HEAD)" new_git_hash="$(git rev-parse --verify HEAD)"
git_updated="false" git_updated="false"
if [ "$old_git_hash" != "$new_git_hash" ]; then if [ "$old_git_hash" != "$new_git_hash" ]; then
log "INFO" "Pulled new changes from origin" log "INFO" "Pulled new changes from origin"
git_updated="true" git_updated="true"
fi fi
docker_updated="false" docker_updated="false"
for image in $(docker ps --filter "name=$service" --format {{.Image}}); do for image in $(docker ps --filter "name=$service" --format {{.Image}}); do
log "INFO" "Checking for Updates of Image: $image" log "INFO" "Checking for Updates of Image: $image"
if docker pull $image | grep "Downloaded newer image"; then if docker pull $image | grep "Downloaded newer image"; then
log "INFO" "$image updated." log "INFO" "$image updated."
docker_updated="true" docker_updated="true"
fi fi
done done
if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then
log "INFO" "Due to previous updates now restarting $service@$1" log "INFO" "Due to previous updates now restarting $service@$1"
systemctl restart "$service@$1.service" systemctl restart "$service@$1.service"
fi fi
log "INFO" "checking updates finished" log "INFO" "checking updates finished"
exit 0 exit 0