summaryrefslogtreecommitdiffstats
path: root/modules.d/90livenet
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 14:01:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 14:01:35 +0000
commite6f2eaf47a177a8eca054d1d70a1b6287e8c3521 (patch)
treec5719e819a9e37df4b54affd61438f382ec38a8f /modules.d/90livenet
parentAdding upstream version 060+5. (diff)
downloaddracut-upstream/102.tar.xz
dracut-upstream/102.zip
Adding upstream version 102.upstream/102
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules.d/90livenet')
-rwxr-xr-xmodules.d/90livenet/livenetroot.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules.d/90livenet/livenetroot.sh b/modules.d/90livenet/livenetroot.sh
index 66dd41b..34f91ff 100755
--- a/modules.d/90livenet/livenetroot.sh
+++ b/modules.d/90livenet/livenetroot.sh
@@ -17,10 +17,21 @@ liveurl="${netroot#livenet:}"
info "fetching $liveurl"
if getargbool 0 'rd.writable.fsimg'; then
+ imgheader=$(curl -sIL "$liveurl")
- imgsize=$(($(curl -sIL "$liveurl" | sed -n 's/Content-Length: *\([[:digit:]]*\).*/\1/p') / (1024 * 1024)))
-
- check_live_ram $imgsize
+ # shellcheck disable=SC2181
+ ret=$?
+ if [ $ret != 0 ]; then
+ warn "failed to get live image header: error $ret"
+ else
+ imgheaderlen=$(echo "$imgheader" | sed -n 's/[cC]ontent-[lL]ength: *\([[:digit:]]*\).*/\1/p')
+ if [ -z "$imgheaderlen" ]; then
+ warn "failed to get 'Content-Length' header from live image"
+ else
+ imgsize=$((imgheaderlen / (1024 * 1024)))
+ check_live_ram $imgsize
+ fi
+ fi
fi
imgfile=
@@ -30,8 +41,9 @@ while [ "$i" -le "$RETRIES" ]; do
imgfile=$(fetch_url "$liveurl")
# shellcheck disable=SC2181
- if [ $? != 0 ]; then
- warn "failed to download live image: error $?"
+ ret=$?
+ if [ $ret != 0 ]; then
+ warn "failed to download live image: error $ret"
imgfile=
fi