summaryrefslogtreecommitdiffstats
path: root/modules.d/90livenet
diff options
context:
space:
mode:
Diffstat (limited to '')
-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