aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/unix
diff options
context:
space:
mode:
Diffstat (limited to 'coin/provisioning/common/unix')
-rwxr-xr-xcoin/provisioning/common/unix/DownloadURL.sh46
1 files changed, 8 insertions, 38 deletions
diff --git a/coin/provisioning/common/unix/DownloadURL.sh b/coin/provisioning/common/unix/DownloadURL.sh
index d3a8a7d0..c1e1d6cc 100755
--- a/coin/provisioning/common/unix/DownloadURL.sh
+++ b/coin/provisioning/common/unix/DownloadURL.sh
@@ -40,51 +40,21 @@
# If called directly from another script, it will exit the parent script
# as well, if not called in its own subshell with parentheses.
-# shellcheck source=try_catch.sh
-source "${BASH_SOURCE%/*}/try_catch.sh"
-
-ExceptionDownloadPrimaryUrl=100
-ExceptionDownloadAltUrl=101
-ExceptionSHA1=102
-
function DownloadURL {
url=$1
url_alt=$2
expectedSha1=$3
targetFile=$4
- try
- (
- try
- (
- echo "Downloading from primary URL '$url'"
- curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || throw $ExceptionDownloadPrimaryUrl
- )
- catch || {
- case $ex_code in
- $ExceptionDownloadPrimaryUrl)
- echo "Failed to download '$url' multiple times"
- echo "Downloading tar.gz from alternative URL '$url_alt'"
- curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt" || throw $ExceptionDownloadAltUrl
- ;;
- esac
- }
- echo "Checking SHA1 on PKG '$targetFile'"
- echo "$expectedSha1 *$targetFile" > $targetFile.sha1
- sha1sum --check $targetFile.sha1 || throw $ExceptionSHA1
+ echo "Downloading from primary URL '$url'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || (
+ echo "Failed to download '$url' multiple times"
+ echo "Downloading from alternative URL '$url_alt'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt"
)
- catch || {
- case $ex_code in
- $ExceptionDownloadAltUrl)
- echo "Failed downloading PKG from primary and alternative URLs"
- exit 1;
- ;;
- $ExceptionSHA1)
- echo "Failed checksum on $targetFile."
- exit 1;
- ;;
- esac
- }
+ echo "Checking SHA1 on PKG '$targetFile'"
+ echo "$expectedSha1 *$targetFile" > $targetFile.sha1
+ sha1sum --check $targetFile.sha1
}