From 4e3a0f79fbe8bea7915b267e132ba1e0d4b67733 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Fri, 20 Sep 2019 13:00:12 +0200 Subject: 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 --- coin/provisioning/common/unix/DownloadURL.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'coin/provisioning') diff --git a/coin/provisioning/common/unix/DownloadURL.sh b/coin/provisioning/common/unix/DownloadURL.sh index da6d772f..0579451f 100755 --- a/coin/provisioning/common/unix/DownloadURL.sh +++ b/coin/provisioning/common/unix/DownloadURL.sh @@ -46,6 +46,15 @@ command -v sha512sum >/dev/null || alias sha512sum='shasum -a 512' ######################################################################## +Download () { + url="$1" + targetFile="$2" + + command -v curl >/dev/null \ + && curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" \ + || wget --tries 5 -O "$targetFile" "$url" +} + VerifyHash () { file=$1 expectedHash=$2 @@ -87,10 +96,10 @@ DownloadURL () { echo "Skipping download, found and validated existing file: $targetFile" else echo "Downloading from primary URL: $url" - if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" + if ! Download "$url" "$targetFile" then echo "FAIL! to download, trying alternative URL: $url2" 1>&2 - if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url2" + if ! Download "$url" "$targetFile" then echo 'FAIL! to download even from alternative url' 1>&2 return 1 -- cgit v1.2.3