]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add sleep and max number of retries
authorNathan Rini <nate@ucar.edu>
Wed, 3 Oct 2018 21:38:08 +0000 (15:38 -0600)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 25 Oct 2019 09:37:43 +0000 (11:37 +0200)
modules.d/90livenet/livenetroot.sh

index b9cbd44495ad03357f4abd770d3941ed69345d44..608480937a81d17b392373f9ed4ba03a2448f2a7 100755 (executable)
@@ -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?