Browse code

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

yuanke wei authored on 2017/09/17 23:18:07
Showing 2 changed files
... ...
@@ -63,7 +63,7 @@ function get_extra_file {
63 63
     if [[ $file_url != file* ]]; then
64 64
         # If the file isn't cache, download it
65 65
         if [[ ! -f $FILES/$file_name ]]; then
66
-            wget --progress=dot:giga -c $file_url -O $FILES/$file_name
66
+            wget --progress=dot:giga -t 2 -c $file_url -O $FILES/$file_name
67 67
             if [[ $? -ne 0 ]]; then
68 68
                 die "$file_url could not be downloaded"
69 69
             fi
... ...
@@ -98,8 +98,8 @@ function install_etcd3 {
98 98
     etcd_file="$(get_extra_file $ETCD_DOWNLOAD_LOCATION)"
99 99
     if [ ! -f "$FILES/etcd-$ETCD_VERSION-linux-$ETCD_ARCH/etcd" ]; then
100 100
         echo "${ETCD_SHA256} $etcd_file" > $FILES/etcd.sha256sum
101
-        # NOTE(sdague): this should go fatal if this fails
102
-        sha256sum -c $FILES/etcd.sha256sum
101
+        # NOTE(yuanke wei): rm the damaged file when checksum fails
102
+        sha256sum -c $FILES/etcd.sha256sum || (sudo rm -f $etcd_file; exit 1)
103 103
 
104 104
         tar xzvf $etcd_file -C $FILES
105 105
         sudo cp $FILES/$ETCD_NAME/etcd $ETCD_BIN_DIR/etcd