Skip to content

Commit 780d680

Browse files
authored
Retry curl when fetching SHASUMS256 file (#168)
1 parent 79d6587 commit 780d680

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

fetch-source/run.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/usr/bin/env bash
22

3+
curl_with_retry()
4+
{
5+
URL=$1
6+
echo "Fetching $URL"
7+
for ((i=1;i<=7;i++)); do
8+
if curl -fsSLO --compressed "$URL"; then
9+
break
10+
else
11+
echo "Curl failed with status $?. Retrying in 10 seconds..."
12+
sleep 10
13+
fi
14+
done
15+
}
16+
317
set -x
418
set -e
519

@@ -24,19 +38,12 @@ for key in ${gpg_keys}; do
2438
done
2539

2640
# Curl with retry
27-
for ((i=1;i<=7;i++)); do
28-
if curl -fsSLO --compressed "$source_url"; then
29-
break
30-
else
31-
echo "Curl failed with status $?. Retrying in 10 seconds..."
32-
sleep 10
33-
fi
34-
done
41+
curl_with_retry "$source_url"
3542

3643
if [[ "$disttype" = "release" ]]; then
37-
curl -fsSLO --compressed "${source_urlbase}/SHASUMS256.txt.asc"
44+
curl_with_retry "${source_urlbase}/SHASUMS256.txt.asc"
3845
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc
3946
grep " node-${fullversion}.tar.xz\$" SHASUMS256.txt | sha256sum -c -
4047
fi
4148

42-
mv -f node-${fullversion}.tar.xz /out/
49+
mv -f node-${fullversion}.tar.xz /out/

0 commit comments

Comments
 (0)