Skip to content

Commit bba4542

Browse files
committed
Added retry logic to all remote calls
1 parent 00211e5 commit bba4542

File tree

1 file changed

+36
-6
lines changed
  • solution_template/vm-linux-terraform/scripts

1 file changed

+36
-6
lines changed

solution_template/vm-linux-terraform/scripts/infra.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,42 @@ sudo apt-get install unzip
88

99
sudo apt-get update
1010

11-
TF_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M ".current_version")
12-
wget -O terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip
13-
wget -O terraform.sha256 https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS
14-
wget -O terraform.sha256.sig https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS.sig
15-
curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import
16-
gpg --verify terraform.sha256.sig terraform.sha256
11+
retry=0
12+
while true;do
13+
TF_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M ".current_version") && break || ((retry++))
14+
((retry >= 10)) && break
15+
done
16+
17+
retry=0
18+
while true;do
19+
wget -O terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip && break || ((retry++))
20+
((retry >= 10)) && break
21+
done
22+
23+
retry=0
24+
while true;do
25+
wget -O terraform.sha256 https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS && break || ((retry++))
26+
((retry >= 10)) && break
27+
done
28+
29+
retry=0
30+
while true;do
31+
wget -O terraform.sha256.sig https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS.sig && break || ((retry++))
32+
((retry >= 10)) && break
33+
done
34+
35+
retry=0
36+
while true;do
37+
curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import && break || ((retry++))
38+
((retry >= 10)) && break
39+
done
40+
41+
retry=0
42+
while true;do
43+
gpg --verify terraform.sha256.sig terraform.sha256 && break || ((retry++))
44+
((retry >= 10)) && break
45+
done
46+
1747
echo $(grep -Po "[[:xdigit:]]{64}(?=\s+terraform_${TF_VERSION}_linux_amd64.zip)" terraform.sha256) terraform.zip | sha256sum -c
1848
unzip terraform.zip
1949
mv terraform /usr/local/bin

0 commit comments

Comments
 (0)