Skip to content

Commit 2217a2d

Browse files
jimisjujokini
authored andcommitted
DownloadURL now works with either wget or curl
The reason is that Ubuntu does not have curl at the very beginning of provisioning scripts, and also does not have the repositories configured in order to install it. Change-Id: Ia485c1672f894bc800f199b742d238b2945938e5 Reviewed-by: Heikki Halmet <[email protected]> (cherry picked from commit 4e3a0f7)
1 parent 8ed0377 commit 2217a2d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

coin/provisioning/common/unix/DownloadURL.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ command -v sha512sum >/dev/null || alias sha512sum='shasum -a 512'
4646
########################################################################
4747

4848

49+
Download () {
50+
url="$1"
51+
targetFile="$2"
52+
53+
command -v curl >/dev/null \
54+
&& curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" \
55+
|| wget --tries 5 -O "$targetFile" "$url"
56+
}
57+
4958
VerifyHash () {
5059
file=$1
5160
expectedHash=$2
@@ -87,10 +96,10 @@ DownloadURL () {
8796
echo "Skipping download, found and validated existing file: $targetFile"
8897
else
8998
echo "Downloading from primary URL: $url"
90-
if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url"
99+
if ! Download "$url" "$targetFile"
91100
then
92101
echo "FAIL! to download, trying alternative URL: $url2" 1>&2
93-
if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url2"
102+
if ! Download "$url" "$targetFile"
94103
then
95104
echo 'FAIL! to download even from alternative url' 1>&2
96105
return 1

0 commit comments

Comments
 (0)