]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
download: Have wget retry 3 times
authorStéphane Graber <stgraber@ubuntu.com>
Mon, 21 Jul 2014 10:25:20 +0000 (12:25 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 31 Jul 2014 17:47:01 +0000 (13:47 -0400)
This forces wget to retry if it gets a network error.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
templates/lxc-download.in

index c96bc31f401380b2877c3c05a32a997aa4590f1a..5799de8267d0f8c838e88a6797e4f989fe2cfbad 100644 (file)
@@ -69,9 +69,19 @@ cleanup() {
     fi
 }
 
+wget_wrapper() {
+    for i in $(seq 3); do
+        if wget $@; then
+            return 0
+        fi
+    done
+
+    return 1
+}
+
 download_file() {
-    if ! wget -T 30 -q https://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
-        if ! wget -T 30 -q http://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
+    if ! wget_wrapper -T 30 -q https://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
+        if ! wget_wrapper -T 30 -q http://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
             if [ "$3" = "noexit" ]; then
                 return 1
             else