Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 41 lines (33 sloc) 1.05 KB
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -z ${VERBOSE+x} ]]; then
set -x
fi
BINS="$HOME/.cache/bin"
DCOS_CLI="$BINS/dcos"
DCOS_CLI_VERSION="0.4.16"
# Returns the version of the currently installed DC/OS CLI binary. e.g 0.4.16
installed_version() {
dcos --version | grep 'dcoscli.version' | cut -d= -f2
}
# Downloads the DC/OS CLI binary for linux with version $DCOS_CLI_VERSION to the cache
install_dcos_cli() {
mkdir -p "$BINS"
curl -sSL "https://downloads.dcos.io/binaries/cli/linux/x86-64/$DCOS_CLI_VERSION/dcos" \
-o "$DCOS_CLI"
chmod u+x "$DCOS_CLI"
}
# Install the DC/OS CLI if it's missing. If it's present, upgrade it if needed otherwise do nothing
if [ ! -e "$DCOS_CLI" ]; then
echo "DC/OS CLI not found. Installing"
install_dcos_cli
else
INSTALLED_VERSION="$(installed_version)"
if [ "$DCOS_CLI_VERSION" != "$INSTALLED_VERSION" ]; then
echo "DC/OS CLI has version $INSTALLED_VERSION, want $DCOS_CLI_VERSION. Upgrading"
rm -rf "$DCOS_CLI"
install_dcos_cli
else
echo "Using cached DC/OS CLI $INSTALLED_VERSION"
fi
fi