Skip to content

Instantly share code, notes, and snippets.

@xarem
Created January 14, 2016 15:34
Show Gist options
  • Save xarem/3ce7f1aaad9b3ca9783b to your computer and use it in GitHub Desktop.
Save xarem/3ce7f1aaad9b3ca9783b to your computer and use it in GitHub Desktop.
Docker Compose Updater Bash Script
#!/bin/bash
lastReleasesUrl="https://github.com/docker/compose/releases.atom"
lastReleaseCache="/tmp/docker-compose-last-release"
if [ -f '/usr/local/bin/docker-compose' ]; then
currentDockerComposeVersion=$(docker-compose -v | egrep -o '([0-9]\.[0-9]\.[0-9])')
else
currentDockerComposeVersion="0.0.0"
fi
if [ ! -f $lastReleaseCache ] || [ "$(( $(date +"%s") - $(stat -c "%Y" $lastReleaseCache) ))" -gt "86400" ]; then
echo 'Aktualisiere docker-compose versionscache'
wget -q -O- $lastReleasesUrl | \
egrep -m1 -o '/docker/compose/releases/tag/([0-9]\.[0-9]\.[0-9])' | \
egrep -o '([0-9]\.[0-9]\.[0-9])' \
> $lastReleaseCache
fi
latestDockerComposeVersion=$(cat $lastReleaseCache)
if [ $latestDockerComposeVersion != $currentDockerComposeVersion ]; then
echo "Aktualisiere docker-compose auf Version ${latestDockerComposeVersion}"
curl -L https://github.com/docker/compose/releases/download/${latestDockerComposeVersion}/docker-compose-`uname -s`-`uname -m` > /tmp/docker-compose && \
mv /tmp/docker-compose /usr/local/bin && \
chmod +x /usr/local/bin/docker-compose && \
chown root:root /usr/local/bin/docker-compose
else
echo 'Keine docker-compose Aktualisierung nötig'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment