From 27e78c2539b19689e0a997af2a7decdbc93052b3 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Sat, 3 Nov 2018 23:10:00 +0800 Subject: Use `if wget ...` in case of wget errors --- functions.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/functions.sh b/functions.sh index efb27a4..7cd6235 100644 --- a/functions.sh +++ b/functions.sh @@ -79,16 +79,17 @@ download_iso() { mkdir -p "$ISOPATH" for url in ${mirrorlist[@]} do - wget -c -O "$ISOPATH/$ISOFILE" "$url/$ISOURL" - if checksum_verify; then - return 0 - else - # checksum bad, may be due to a bad partial download - # so remove the file and try again - rm -f "$ISOPATH/$ISOFILE" - wget -O "$ISOPATH/$ISOFILE" "$url/$ISOURL" - checksum_verify && return 0 - rm -f "$ISOPATH/$ISOFILE" # then try next mirror + if wget -c -O "$ISOPATH/$ISOFILE" "$url/$ISOURL"; then + if checksum_verify; then + return 0 + else + # checksum bad, may be due to a bad partial download + # so remove the file and try again + rm -f "$ISOPATH/$ISOFILE" + wget -O "$ISOPATH/$ISOFILE" "$url/$ISOURL" + checksum_verify && return 0 + rm -f "$ISOPATH/$ISOFILE" # then try next mirror + fi fi done fatalerror "Fail to download $ISOFILE!" -- cgit v1.2.3