add terraform download helper
authorSven Hoexter <sven@stormbind.net>
Tue, 17 Sep 2019 20:13:01 +0000 (22:13 +0200)
committerSven Hoexter <sven@stormbind.net>
Tue, 17 Sep 2019 20:13:01 +0000 (22:13 +0200)
artifactory/terraform-dl.sh [new file with mode: 0755]

diff --git a/artifactory/terraform-dl.sh b/artifactory/terraform-dl.sh
new file mode 100755 (executable)
index 0000000..19e5e34
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+LATEST_LINK="https://github.com/hashicorp/terraform/releases/latest"
+VERSION="$(curl -si ${LATEST_LINK} | grep Location | grep -Po '[0-9]\.[0-9]{1,2}\.[0-9]+')"
+BASE_DOWNLOAD="https://releases.hashicorp.com/terraform/${VERSION}/"
+ARCH="amd64"
+OS="linux"
+TF_FILE="terraform_${VERSION}_${OS}_${ARCH}.zip"
+TF_SUM="terraform_${VERSION}_SHA256SUMS"
+TF_SIG="terraform_${VERSION}_SHA256SUMS.sig"
+BUILD_DIR="/tmp/terraform"
+
+mkdir -p ${BUILD_DIR}
+cd ${BUILD_DIR}
+
+echo "
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mQENBFMORM0BCADBRyKO1MhCirazOSVwcfTr1xUxjPvfxD3hjUwHtjsOy/bT6p9f
+W2mRPfwnq2JB5As+paL3UGDsSRDnK9KAxQb0NNF4+eVhr/EJ18s3wwXXDMjpIifq
+fIm2WyH3G+aRLTLPIpscUNKDyxFOUbsmgXAmJ46Re1fn8uKxKRHbfa39aeuEYWFA
+3drdL1WoUngvED7f+RnKBK2G6ZEpO+LDovQk19xGjiMTtPJrjMjZJ3QXqPvx5wca
+KSZLr4lMTuoTI/ZXyZy5bD4tShiZz6KcyX27cD70q2iRcEZ0poLKHyEIDAi3TM5k
+SwbbWBFd5RNPOR0qzrb/0p9ksKK48IIfH2FvABEBAAG0K0hhc2hpQ29ycCBTZWN1
+cml0eSA8c2VjdXJpdHlAaGFzaGljb3JwLmNvbT6JATgEEwECACIF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ms0NgZ2Uknqn1WRU1Ki7rE4sTy68iZtWpKQXZEJa0IGnuI2sSINGcXCJ
+oEIgXTMyCILo34Fa/C6VCm2WBgz9zZO8/rHIiQm1J5zqz0DrDwKBUM9C
+=LYpS
+-----END PGP PUBLIC KEY BLOCK-----
+" > hashicorp.asc
+gpg --import hashicorp.asc
+
+for x in ${TF_FILE} ${TF_SUM} ${TF_SIG}; do
+    echo "${BASE_DOWNLOAD}${x}"
+    curl -C - -OJLs "${BASE_DOWNLOAD}${x}"
+done
+
+gpg --verify ${TF_SIG} || ( echo "Verification of GPG sig failed"; exit 1 )
+grep ${TF_FILE} ${TF_SUM} | sha256sum -c - || ( echo "Verification of SHA2 failed"; exit 1 )
+unzip -o ${TF_FILE}