From 734d725d62d2cbe4445524448de024e3b9e7f4b3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 3 Jun 2024 16:01:37 +0200 Subject: Merging upstream version 102. Signed-off-by: Daniel Baumann --- modules.d/90livenet/livenetroot.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'modules.d/90livenet') 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 -- cgit v1.2.3