Skip to content

Instantly share code, notes, and snippets.

@tristanmorgan
Last active June 14, 2024 00:46
Show Gist options
  • Save tristanmorgan/3a3e105e920ad574748034aaf07e0d77 to your computer and use it in GitHub Desktop.
Save tristanmorgan/3a3e105e920ad574748034aaf07e0d77 to your computer and use it in GitHub Desktop.
Quick script to download latest HashiCorp binaries. (for arm mac)
#!/bin/sh
set -e
export CHECKPOINT_DISABLE=1
download() {
echo checking $1
TF_TAGS_FEED="https://api.releases.hashicorp.com/v1/releases/$1/latest"
RELEASE_JSON=$(curl -s -H "Cache-Control: no-cache" "$TF_TAGS_FEED")
LATEST_VERSION=$(echo ${RELEASE_JSON} | jq -r .version )
CURRENT_VERSION=$(~/bin/$1 -version 2>&1 | awk ' {match($0,/[0-9\.]+/); print substr($0,RSTART,RLENGTH); exit}' || echo 0.0.0)
if [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
TMPDIR=$(mktemp -d)
go-getter -progress $(echo ${RELEASE_JSON} | jq -r '.builds[] | select(.os == "darwin") | select(.arch == "arm64") | .url') ${TMPDIR} || return 0
install ${TMPDIR}/$1 ~/bin/$1
rm -r ${TMPDIR}
else
echo No update available for $1
fi
}
# download 'boundary'
download 'consul'
# download 'consul-template'
# download 'consul-terraform-sync'
# download 'envconsul'
download 'nomad'
download 'packer'
# download 'sentinel'
download 'terraform'
download 'vault'
download 'vlt'
# download 'waypoint'
download 'hcdiag'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment