Terraform quick ref

From UVOO Tech Wiki
Revision as of 18:55, 7 December 2022 by Busk (talk | contribs) (Created page with "``` #!/bin/sh set -eu if [ "$#" -ne 1 ]; then echo "Usage: $0 <terraform version>" echo "Example: $0 1.3.6" exit fi version=$1 curl -sLO https://releases.hashicorp.com/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/bin/sh
set -eu
if [ "$#" -ne 1 ]; then
  echo "Usage: $0 <terraform version>"
  echo "Example: $0 1.3.6"
  exit
fi

version=$1
curl -sLO https://releases.hashicorp.com/terraform/${version}/terraform_${version}_SHA256SUMS
curl -sLO https://releases.hashicorp.com/terraform/${version}/terraform_${version}_linux_amd64.zip
sha256_sig=$(cat terraform_${version}_SHA256SUMS | grep terraform_${version}_linux_amd64.zip | cut -d " " -f 1)
sha256_file=$(sha256sum terraform_${version}_linux_amd64.zip | awk '{print $1}')
if [ ! "${sha256_file}" = "${sha256_sig}" ]; then
  echo "I: The sha256 for file does not match signature from web. Check file integrity."
  exit 1
fi
unzip terraform_${version}_linux_amd64.zip
mv terraform /usr/local/bin/