Created
March 15, 2018 21:01
-
-
Save jwieringa/96cd5a0ca366a8590a177fc3062a578a to your computer and use it in GitHub Desktop.
Amazon linux hashicorp install script
This file contains hidden or 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
#!/bin/bash | |
# Author: Jason Wieringa | |
# | |
# General script for installing Hashicorp tools. | |
set -e | |
: ${PRODUCT:?"Set to desired Hashicorp product"} | |
: ${VERSION:?"Set to desired Hashicorp product version"} | |
SYSTEM=$(uname | tr '[:upper:]' '[:lower:]') | |
UNAME=$(uname -m) | |
NAME=${PRODUCT}_$(sed 's/\./_/g' <<< "${VERSION}") | |
if [ "$UNAME" != "x86_64" ]; then | |
ARCH=386 | |
else | |
ARCH=amd64 | |
fi | |
mkdir -p /root/.gnupg | |
curl --retry 10 -sf https://keybase.io/hashicorp/pgp_keys.asc | gpg --import | |
TEMP_DIR=$(mktemp -d) | |
pushd $TEMP_DIR | |
curl --retry 10 -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_${SYSTEM}_${ARCH}.zip | |
curl --retry 10 -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_SHA256SUMS | |
curl --retry 10 -sfO https://releases.hashicorp.com/${PRODUCT}/${VERSION}/${PRODUCT}_${VERSION}_SHA256SUMS.sig | |
gpg --batch --verify ${PRODUCT}_${VERSION}_SHA256SUMS.sig ${PRODUCT}_${VERSION}_SHA256SUMS | |
egrep "_${SYSTEM}_${ARCH}" ${PRODUCT}_${VERSION}_SHA256SUMS | sha256sum --check - | |
unzip -o -d $TEMP_DIR "${PRODUCT}_${VERSION}_${SYSTEM}_${ARCH}.zip" | |
mv $TEMP_DIR/terraform /usr/local/bin/${NAME} | |
popd | |
rm -rf $TEMP_DIR | |
if [ ! -f /usr/local/bin/${NAME} ]; then | |
echo "Failed to install ${PRODUCT} ${VERSION}" | |
else | |
echo "${PRODUCT} ${VERSION} successfully installed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment