From: Stéphane Graber Date: Mon, 21 Jul 2014 10:25:20 +0000 (+0200) Subject: download: Have wget retry 3 times X-Git-Tag: lxc-1.1.0.alpha2~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acabe1faee82d44db391345a8a51b9dec3dc0229;p=thirdparty%2Flxc.git download: Have wget retry 3 times This forces wget to retry if it gets a network error. Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/templates/lxc-download.in b/templates/lxc-download.in index c96bc31f4..5799de826 100644 --- a/templates/lxc-download.in +++ b/templates/lxc-download.in @@ -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