Commit 773ae069 authored by johandegn's avatar johandegn
Browse files

Removed old scripts

parent d8d36db2
Pipeline #52031 passed with stage
in 42 seconds
#!/bin/bash
url="registry.gitlab.au.dk/exsys2021/da6/hold-afstand"
old_digest=$(docker inspect -f '{{.RepoDigests}}' ${url}:active | grep -o 'sha256:[0-9A-Fa-f]*')
# probably no existing image
if [ $? -ne 0 ]; then
echo "No existing image! Abort."
exit 1;
fi
new_digest=$(docker pull ${url}:latest | grep Digest | sed 's/Digest: //')
# network error or authentication might go wrong
if [ $? -ne 0 ]; then
echo "Auth or network err! Abort."
exit 2;
fi
# sanity check that new digest is formatted correctly and is same length as old.
# if it aint, it could be the result of a gitlab server error or such.
check=$(echo $new_digest | grep -o 'sha256:[0-9A-Fa-f]*')
if [ "${#check}" -eq "0" ] || [ ${#old_digest} -ne ${#new_digest} ]; then
echo "Damnit, something went bad! Crash and burn.."
exit 3;
fi
echo "Old digest: $old_digest"
echo "New digest: $new_digest"
echo
if [ "$old_digest" != "$new_digest" ]; then
echo "Deploying new docker instance."
docker stop studerende-au
docker rm studerende-au
docker rmi ${url}:active
docker tag ${url}:latest ${url}:active
docker run -p 80:80 -p 443:443 --name studerende-au -d ${url}:active
# notify slack channel
/home/auuser/slack-notifier.sh "A new version of the website has been deployed! Check it out: https://vm34.exsys2021.cs.au.dk/"
else
echo "Already up to date."
fi
# remove/untag file. silence output
docker rmi registry.gitlab.au.dk/exsys2021/da6/hold-afstand:latest >/dev/null 2>&1
echo "Done."
#!/bin/bash
docker pull registry.gitlab.au.dk/exsys2021/da6/hold-afstand:latest
docker stop studerende-au
docker rm studerende-au
docker rmi registry.gitlab.au.dk/exsys2021/da6/hold-afstand:active
docker tag registry.gitlab.au.dk/exsys2021/da6/hold-afstand:latest registry.gitlab.au.dk/exsys2021/da6/hold-afstand:active
docker run -p 80:80 -p 443:443 --name studerende-au -d registry.gitlab.au.dk/exsys2021/da6/hold-afstand:active
docker rmi registry.gitlab.au.dk/exsys2021/da6/hold-afstand:latest
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment