From c652a498fb6ae1cdd7480b590be0f1e843768666 Mon Sep 17 00:00:00 2001 From: yuanke wei Date: Sun, 17 Sep 2017 22:18:07 +0800 Subject: [PATCH] Fix partial download problem (1) when checksum fails, better delete the broken files and try the second time; (2) amazon s3 is not good in mainland China, better try one more time with wget Change-Id: I24ee73f216b78bd80564863cd335e5d5a9b56360 --- functions | 2 +- lib/etcd3 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 33a0e6aaf5..8b69c73bba 100644 --- a/functions +++ b/functions @@ -63,7 +63,7 @@ function get_extra_file { if [[ $file_url != file* ]]; then # If the file isn't cache, download it if [[ ! -f $FILES/$file_name ]]; then - wget --progress=dot:giga -c $file_url -O $FILES/$file_name + wget --progress=dot:giga -t 2 -c $file_url -O $FILES/$file_name if [[ $? -ne 0 ]]; then die "$file_url could not be downloaded" fi diff --git a/lib/etcd3 b/lib/etcd3 index 60e827add2..934bbb004f 100644 --- a/lib/etcd3 +++ b/lib/etcd3 @@ -98,8 +98,8 @@ function install_etcd3 { etcd_file="$(get_extra_file $ETCD_DOWNLOAD_LOCATION)" if [ ! -f "$FILES/etcd-$ETCD_VERSION-linux-$ETCD_ARCH/etcd" ]; then echo "${ETCD_SHA256} $etcd_file" > $FILES/etcd.sha256sum - # NOTE(sdague): this should go fatal if this fails - sha256sum -c $FILES/etcd.sha256sum + # NOTE(yuanke wei): rm the damaged file when checksum fails + sha256sum -c $FILES/etcd.sha256sum || (sudo rm -f $etcd_file; exit 1) tar xzvf $etcd_file -C $FILES sudo cp $FILES/$ETCD_NAME/etcd $ETCD_BIN_DIR/etcd