Skip to content

Instantly share code, notes, and snippets.

@tristanmorgan
Last active October 28, 2022 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
go-getter -progress $(echo ${RELEASE_JSON} | jq -r '.builds[] | select(.os == "darwin") | select(.arch == "arm64") | .url') . || return 0
install ./$1 ~/bin/$1
rm ./$1
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 'waypoint'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment