Skip to content

Instantly share code, notes, and snippets.

@fvoges
Last active November 3, 2023 11:33
Show Gist options
  • Save fvoges/ba995430914ae4d248374e766a4062f2 to your computer and use it in GitHub Desktop.
Save fvoges/ba995430914ae4d248374e766a4062f2 to your computer and use it in GitHub Desktop.
Useful HashiCorp binaries scripts
#!/usr/bin/env bash -e
# Original source: https://gist.github.com/greenbrian/2e9e90d65c3d272c48b14dd3b3f19153
DEPS="curl jq unzip wget"
for cmd in $DEPS
do
if ! which -s $cmd
then
echo "$cmd command not found!"
echo "Ensure that you have the following tools installed and in your \$PATH: ${DEPS}"
exit 1
fi
done
function get_latest {
product="$1"
curl -s "https://api.releases.hashicorp.com/v1/releases/${product}/latest?license_class=oss"|jq -r 'select(.status.state == "supported") |.version'
}
LINUX_ARCH="amd64"
MACOS_ARCH="amd64"
BINDIR="${HOME}/hashi-binaries"
BOUNDARY_VERSION="$(get_latest boundary)"
CONSUL_VERSION="$(get_latest consul)"
CONSUL_TEMPLATE_VERSION="$(get_latest consul-template)"
ENVCONSUL_VERSION="$(get_latest envconsul)"
NOMAD_VERSION="$(get_latest nomad)"
TERRAFORM_VERSION="$(get_latest terraform)"
VAULT_VERSION="$(get_latest vault)"
WAYPOINT_VERSION="$(get_latest waypoint)"
# Copy updated Linux binaries to these destinations (for Vagrant projects mostly)
BINARY_LOCATIONS="${HOME}/src/vagrant/common/bin"
[ -d ${BINDIR} ] || mkdir ${BINDIR}
[ -d ${BINDIR}/boundary ] || mkdir ${BINDIR}/boundary
[ -d ${BINDIR}/consul ] || mkdir ${BINDIR}/consul
[ -d ${BINDIR}/consul-template ] || mkdir ${BINDIR}/consul-template
[ -d ${BINDIR}/envconsul ] || mkdir ${BINDIR}/envconsul
[ -d ${BINDIR}/nomad ] || mkdir ${BINDIR}/nomad
[ -d ${BINDIR}/terraform ] || mkdir ${BINDIR}/terraform
[ -d ${BINDIR}/vault ] || mkdir ${BINDIR}/vault
[ -d ${BINDIR}/waypoint ] || mkdir ${BINDIR}/waypoint
[ -d ${BINARY_LOCATIONS} ] || mkdir ${BINARY_LOCATIONS}
echo "Downloading Boundary version ${BOUNDARY_VERSION}"
cd ${BINDIR}/boundary/
wget -qc "https://releases.hashicorp.com/boundary/${BOUNDARY_VERSION}/boundary_${BOUNDARY_VERSION}_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/boundary/${BOUNDARY_VERSION}/boundary_${BOUNDARY_VERSION}_darwin_${MACOS_ARCH}.zip"
echo "Downloading Consul Enterprise version ${CONSUL_VERSION}"
cd ${BINDIR}/consul/
wget -qc "https://releases.hashicorp.com/consul/${CONSUL_VERSION}+ent/consul_${CONSUL_VERSION}+ent_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/consul/${CONSUL_VERSION}+ent/consul_${CONSUL_VERSION}+ent_darwin_${MACOS_ARCH}.zip"
echo "Downloading Consul Template version ${CONSUL_TEMPLATE_VERSION}"
cd ${BINDIR}/consul-template/
wget -qc "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_darwin_${MACOS_ARCH}.zip"
echo "Downloading Envconsul version ${ENVCONSUL_VERSION}"
cd ${BINDIR}/envconsul/
wget -qc "https://releases.hashicorp.com/envconsul/${ENVCONSUL_VERSION}/envconsul_${ENVCONSUL_VERSION}_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/envconsul/${ENVCONSUL_VERSION}/envconsul_${ENVCONSUL_VERSION}_darwin_${MACOS_ARCH}.zip"
echo "Downloading Nomad Enterprise version ${NOMAD_VERSION}"
cd ${BINDIR}/nomad/
wget -qc "https://releases.hashicorp.com/nomad/${NOMAD_VERSION}+ent/nomad_${NOMAD_VERSION}+ent_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/nomad/${NOMAD_VERSION}+ent/nomad_${NOMAD_VERSION}+ent_darwin_${MACOS_ARCH}.zip"
echo "Downloading Terraform version ${TERRAFORM_VERSION}"
cd ${BINDIR}/terraform/
wget -qc "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_darwin_${MACOS_ARCH}.zip"
echo "Downloading Vault Enterprise version ${VAULT_VERSION}"
cd ${BINDIR}/vault/
wget -qc "https://releases.hashicorp.com/vault/${VAULT_VERSION}+ent/vault_${VAULT_VERSION}+ent_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/vault/${VAULT_VERSION}+ent/vault_${VAULT_VERSION}+ent_darwin_${MACOS_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/vault/${VAULT_VERSION}+ent.hsm/vault_${VAULT_VERSION}+ent.hsm_linux_${LINUX_ARCH}.zip"
echo "Downloading Waypoint version ${WAYPOINT_VERSION}"
cd ${BINDIR}/waypoint/
wget -qc "https://releases.hashicorp.com/waypoint/${WAYPOINT_VERSION}/waypoint_${WAYPOINT_VERSION}_linux_${LINUX_ARCH}.zip"
wget -qc "https://releases.hashicorp.com/waypoint/${WAYPOINT_VERSION}/waypoint_${WAYPOINT_VERSION}_darwin_${MACOS_ARCH}.zip"
echo
# install boundary locally
unzip -qqo "${BINDIR}/boundary/boundary_${BOUNDARY_VERSION}_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/boundary
echo "########################################################################################################"
echo "Boundary installed:"
/usr/local/bin/boundary -version
echo "########################################################################################################"
echo
# install consul locally
unzip -qqo "${BINDIR}/consul/consul_${CONSUL_VERSION}+ent_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/consul
echo "########################################################################################################"
echo "Consul Enterprise installed:"
/usr/local/bin/consul -version
echo "########################################################################################################"
echo
# install consul-template locally
unzip -qqo "${BINDIR}/consul-template/consul-template_${CONSUL_TEMPLATE_VERSION}_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/consul-template
echo "########################################################################################################"
echo "Consul Template installed:"
/usr/local/bin/consul-template -version
echo "########################################################################################################"
echo
# install envconsul locally
unzip -qqo "${BINDIR}/envconsul/envconsul_${ENVCONSUL_VERSION}_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/envconsul
echo "########################################################################################################"
echo "Envconsul installed:"
/usr/local/bin/envconsul -version
echo "########################################################################################################"
echo
# install nomad locally
unzip -qqo "${BINDIR}/nomad/nomad_${NOMAD_VERSION}+ent_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/nomad
echo "########################################################################################################"
echo "Nomad Enterprise installed:"
/usr/local/bin/nomad -version
echo "########################################################################################################"
echo
# install terraform locally
unzip -qqo "${BINDIR}/terraform/terraform_${TERRAFORM_VERSION}_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/terraform
echo "########################################################################################################"
echo "Terraform installed:"
/usr/local/bin/terraform -version
echo "########################################################################################################"
echo
# install vault locally
unzip -qqo "${BINDIR}/vault/vault_${VAULT_VERSION}+ent_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/vault
echo "########################################################################################################"
echo "Vault Enterprise installed:"
/usr/local/bin/vault -version
echo "########################################################################################################"
echo
# install waypoint locally
unzip -qqo "${BINDIR}/waypoint/waypoint_${WAYPOINT_VERSION}_darwin_${MACOS_ARCH}.zip" -d /usr/local/bin/
chmod +x /usr/local/bin/waypoint
echo "########################################################################################################"
echo "Waypoint installed:"
/usr/local/bin/waypoint -version
echo "########################################################################################################"
echo
# unzip linux boundary binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/boundary/boundary_${BOUNDARY_VERSION}_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux consul binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/consul/consul_${CONSUL_VERSION}+ent_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux consul-template binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/consul-template/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux consul binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/envconsul/envconsul_${ENVCONSUL_VERSION}_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux nomad binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/nomad/nomad_${NOMAD_VERSION}+ent_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux terraform binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/terraform/terraform_${TERRAFORM_VERSION}_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux vault binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/vault/vault_${VAULT_VERSION}+ent_linux_${LINUX_ARCH}.zip" -d $location
done
# unzip linux waypoint binary
for location in $BINARY_LOCATIONS; do
unzip -qqo "${BINDIR}/waypoint/waypoint_${WAYPOINT_VERSION}_linux_${LINUX_ARCH}.zip" -d $location
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment