Skip to content

Instantly share code, notes, and snippets.

@jwieringa
Created August 12, 2017 02:44
Show Gist options
  • Save jwieringa/ea7b7ea5f106dda060de3fbbd47e0f99 to your computer and use it in GitHub Desktop.
Save jwieringa/ea7b7ea5f106dda060de3fbbd47e0f99 to your computer and use it in GitHub Desktop.
#!/bin/bash
: ${PRODUCT:?"Set to desired Hashicorp product"}
: ${VERSION:?"Set to desired Hashicorp product version"}
: ${ARCH:?"Set to system architecture"}
SYSTEM=$(uname | tr '[:upper:]' '[:lower:]')
curl -sf https://keybase.io/hashicorp/pgp_keys.asc | /bin/gpg --import
mkdir -p /tmp/${PRODUCT}
pushd /tmp/${PRODUCT}
/bin/curl -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_${SYSTEM}_${ARCH}.zip
/bin/curl -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_SHA256SUMS
/bin/curl -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_SHA256SUMS.sig
/bin/gpg --batch --verify ${PRODUCT}_${VERSION}_SHA256SUMS.sig /tmp/${PRODUCT}/${PRODUCT}_${VERSION}_SHA256SUMS
/bin/egrep "_${SYSTEM}_${ARCH}" ${PRODUCT}_${VERSION}_SHA256SUMS | /bin/sha256sum -c -
mkdir -p /opt/bin
unzip -o -d /opt/bin "${PRODUCT}_${VERSION}_${SYSTEM}_${ARCH}.zip"
popd
rm -rf /tmp/${PRODUCT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment