From bba4542867550692a62c70de255dd55dfa766576 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline Date: Fri, 2 Mar 2018 19:47:59 -0800 Subject: [PATCH] Added retry logic to all remote calls --- .../vm-linux-terraform/scripts/infra.sh | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/solution_template/vm-linux-terraform/scripts/infra.sh b/solution_template/vm-linux-terraform/scripts/infra.sh index 3b5d4b2f..4eff0f78 100644 --- a/solution_template/vm-linux-terraform/scripts/infra.sh +++ b/solution_template/vm-linux-terraform/scripts/infra.sh @@ -8,12 +8,42 @@ sudo apt-get install unzip sudo apt-get update -TF_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M ".current_version") -wget -O terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip -wget -O terraform.sha256 https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS -wget -O terraform.sha256.sig https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS.sig -curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import -gpg --verify terraform.sha256.sig terraform.sha256 +retry=0 +while true;do +TF_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M ".current_version") && break || ((retry++)) +((retry >= 10)) && break +done + +retry=0 +while true;do +wget -O terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip && break || ((retry++)) +((retry >= 10)) && break +done + +retry=0 +while true;do +wget -O terraform.sha256 https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS && break || ((retry++)) +((retry >= 10)) && break +done + +retry=0 +while true;do +wget -O terraform.sha256.sig https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS.sig && break || ((retry++)) +((retry >= 10)) && break +done + +retry=0 +while true;do +curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import && break || ((retry++)) +((retry >= 10)) && break +done + +retry=0 +while true;do +gpg --verify terraform.sha256.sig terraform.sha256 && break || ((retry++)) +((retry >= 10)) && break +done + echo $(grep -Po "[[:xdigit:]]{64}(?=\s+terraform_${TF_VERSION}_linux_amd64.zip)" terraform.sha256) terraform.zip | sha256sum -c unzip terraform.zip mv terraform /usr/local/bin