Created
March 2, 2020 07:25
-
-
Save hongkongkiwi/27e5616143e432b5c72d19bf6af03af6 to your computer and use it in GitHub Desktop.
Helper script to update docker-machine to latest version from github. Could be run in cron if you want to keep up to date. Can modify to be applicable to any app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
[ "$EUID" -ne 0 ] && { echo >&2 "Please run as root or with sudo"; exit 2; } | |
INSTALL_LOCATION="/usr/local/bin/docker-machine" | |
REPO=docker/machine | |
VERSION=`curl -s "https://github.com/${REPO}/releases/latest/download" 2>&1 | grep -Po [0-9]+\.[0-9]+\.[0-9]+` | |
[ -z "$VERSION" ] && echo >&2 "Could not get latest version from ${REPO}!" | |
if command -v docker-machine >/dev/null 2>&1; then | |
CURRENT_VERSION=`docker-machine --version | grep -Po [0-9]+\.[0-9]+\.[0-9]+` | |
[[ "$CURRENT_VERSION" == "$VERSION" ]] && { echo >&2 "Docker Machine is already the latest version $VERSION"; exit 1; } | |
fi | |
echo "Downlaoding Docker Machine v${VERSION}" && \ | |
curl -s -L "https://github.com/${REPO}/releases/download/v${VERSION}/docker-machine-`uname -s`-`uname -m`" >"/tmp/docker-machine" && \ | |
echo "Installing Docker Machine" && \ | |
install "/tmp/docker-machine" "$INSTALL_LOCATION" && echo "Done!" || echo >&2 "Failed!" | |
[ -f "/tmp/docker-machine" ] && rm "/tmp/docker-machine" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment