Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[semver:patch] Check SHA256SUM of downloaded file #27

Merged
merged 6 commits into from
May 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/commands/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ steps:
- run:
name: Install terraform binary
command: |
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
wget -P /tmp https://releases.hashicorp.com/terraform/<< parameters.terraform_version >>/terraform_<< parameters.terraform_version >>_<< parameters.os >>_<< parameters.arch >>.zip
wget -nv https://releases.hashicorp.com/terraform/<< parameters.terraform_version >>/terraform_<< parameters.terraform_version >>_SHA256SUMS

# Validate checksum
expected_sha=$(cat terraform_<< parameters.terraform_version >>_SHA256SUMS | grep "terraform_<< parameters.terraform_version >>_<< parameters.os >>_<< parameters.arch >>.zip" | awk '{print $1}')
download_sha=$(shasum -a 256 "/tmp/terraform_<< parameters.terraform_version >>_<< parameters.os >>_<< parameters.arch >>.zip" | cut -d' ' -f1)
echo "Validating download..."
if [ $expected_sha != $download_sha ]; then
echo "Expected SHA256SUM does not match downloaded file, exiting."
exit 1
fi

if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
unzip -o /tmp/terraform_<< parameters.terraform_version >>_<< parameters.os >>_<< parameters.arch >>.zip -d /tmp
$SUDO mv /tmp/terraform /usr/local/bin
terraform version