diff options
author | Iru Cai <mytbk920423@gmail.com> | 2016-08-06 13:14:38 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2016-08-06 13:14:38 +0800 |
commit | 25545a33aab48c1c9780e5a634d5f94d623f8930 (patch) | |
tree | 7f693c08162fe73678659492b93766d323b830b6 | |
parent | 6bc7f72a6c72714e55d687f108bdde8adb287c0c (diff) | |
download | liveusb-builder-25545a33aab48c1c9780e5a634d5f94d623f8930.tar.xz |
download files with wget's -c option
-rwxr-xr-x | buildlive | 5 | ||||
-rw-r--r-- | functions.sh | 14 |
2 files changed, 14 insertions, 5 deletions
@@ -66,11 +66,10 @@ echo "uuid=$UUID" > "$GRUBCFG" for i in ${DISTROLIST[@]} do process_distro "$i" - if [ -f "isofiles/$ISOFILE" ]; then - checksum_verify + if [ -f "isofiles/$ISOFILE" ] && checksum_verify; then + true else download_iso - checksum_verify fi install_live diff --git a/functions.sh b/functions.sh index 1ee9590..07e3c15 100644 --- a/functions.sh +++ b/functions.sh @@ -16,7 +16,7 @@ checksum_verify() { if [[ $_cksum == $_hashsum ]]; then msg "$ISOFILE ok." else - fatalerror "$ISOFILE checksum bad!" + msg "$ISOFILE checksum bad!" && return 1 fi } @@ -32,7 +32,17 @@ download_iso() { mkdir -p isofiles for url in ${MIRRORLIST[@]} do - wget -O "isofiles/$ISOFILE" "$url/$ISOURL" && return 0 + wget -c -O "isofiles/$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 "isofiles/$ISOFILE" + wget -O "isofiles/$ISOFILE" "$url/$ISOURL" + checksum_verify && return 0 + rm -f "isofiles/$ISOFILE" # then try next mirror + fi done fatalerror "Fail to download $ISOFILE!" } |