From: Nathan Rini Date: Wed, 3 Oct 2018 21:38:08 +0000 (-0600) Subject: add sleep and max number of retries X-Git-Tag: 050~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66bfa66add11c38dd0d4471956d7119983d03d5e;p=thirdparty%2Fdracut.git add sleep and max number of retries --- diff --git a/modules.d/90livenet/livenetroot.sh b/modules.d/90livenet/livenetroot.sh index b9cbd4449..608480937 100755 --- a/modules.d/90livenet/livenetroot.sh +++ b/modules.d/90livenet/livenetroot.sh @@ -6,6 +6,8 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh . /lib/url-lib.sh PATH=/usr/sbin:/usr/bin:/sbin:/bin +RETRIES={RETRIES:-100} +SLEEP={SLEEP:-5} [ -e /tmp/livenet.downloaded ] && exit 0 @@ -15,7 +17,8 @@ liveurl="${netroot#livenet:}" info "fetching $liveurl" imgfile= -until [ ! -z "$imgfile" -a -s "$imgfile" ] +#retry until the imgfile is populated with data or the max retries +for (( i=1; i<=$RETRIES; i++)) do imgfile=$(fetch_url "$liveurl") @@ -23,6 +26,12 @@ do warn "failed to download live image: error $?" imgfile= fi + + if [ ! -z "$imgfile" -a -s "$imgfile" ]; then + break + else + sleep $SLEEP + fi done > /tmp/livenet.downloaded # TODO: couldn't dmsquash-live-root handle this?