]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/90livenet/livenetroot.sh
2 # livenetroot - fetch a live image from the network and run it
4 type getarg
> /dev
/null
2>&1 || .
/lib
/dracut-lib.sh
8 PATH
=/usr
/sbin
:/usr
/bin
:/sbin
:/bin
9 RETRIES
=${RETRIES:-100}
12 [ -e /tmp
/livenet.downloaded
] && exit 0
14 # args get passed from 40network/netroot
16 liveurl
="${netroot#livenet:}"
17 info
"fetching $liveurl"
19 if getargbool
0 'rd.writable.fsimg'; then
21 imgsize
=$
(($
(curl
-sIL "$liveurl" |
sed -n 's/Content-Length: *\([[:digit:]]*\).*/\1/p') / (1024 * 1024)))
23 check_live_ram
$imgsize
27 #retry until the imgfile is populated with data or the max retries
29 while [ "$i" -le "$RETRIES" ]; do
30 imgfile
=$
(fetch_url
"$liveurl")
32 # shellcheck disable=SC2181
34 warn
"failed to download live image: error $?"
38 if [ -n "$imgfile" -a -s "$imgfile" ]; then
41 if [ $i -ge "$RETRIES" ]; then
42 warn
"failed to download live image after $i attempts."
50 done > /tmp
/livenet.downloaded
52 # TODO: couldn't dmsquash-live-root handle this?
53 if [ "${imgfile##*.}" = "iso" ]; then
55 losetup
"$root" "$imgfile"
60 exec /sbin
/dmsquash-live-root
"$root"