Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(livenet): some fixes related to getting live image size #2611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions modules.d/90livenet/livenetroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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

Expand Down
Loading