summaryrefslogtreecommitdiffstats
path: root/modules.d/90dmsquash-live/parse-dmsquash-live.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/90dmsquash-live/parse-dmsquash-live.sh')
-rwxr-xr-xmodules.d/90dmsquash-live/parse-dmsquash-live.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/modules.d/90dmsquash-live/parse-dmsquash-live.sh b/modules.d/90dmsquash-live/parse-dmsquash-live.sh
new file mode 100755
index 0000000..de910b3
--- /dev/null
+++ b/modules.d/90dmsquash-live/parse-dmsquash-live.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# live images are specified with
+# root=live:backingdev
+
+[ -z "$root" ] && root=$(getarg root=)
+
+# support legacy syntax of passing liveimg and then just the base root
+if getargbool 0 rd.live.image -d -y liveimg; then
+ liveroot="live:$root"
+fi
+
+if [ "${root%%:*}" = "live" ]; then
+ liveroot=$root
+fi
+
+[ "${liveroot%%:*}" = "live" ] || return 1
+
+modprobe -q loop
+
+case "$liveroot" in
+ live:LABEL=* | LABEL=* | live:UUID=* | UUID=* | live:PARTUUID=* | PARTUUID=* | live:PARTLABEL=* | PARTLABEL=*)
+ root="live:$(label_uuid_to_dev "${root#live:}")"
+ rootok=1
+ ;;
+ live:CDLABEL=* | CDLABEL=*)
+ root="${root#live:}"
+ root="$(echo "$root" | sed 's,/,\\x2f,g;s, ,\\x20,g')"
+ root="live:/dev/disk/by-label/${root#CDLABEL=}"
+ rootok=1
+ ;;
+ live:/*.[Ii][Ss][Oo] | /*.[Ii][Ss][Oo])
+ root="${root#live:}"
+ root="liveiso:${root}"
+ rootok=1
+ ;;
+ live:/dev/*)
+ root="live:${root#live:}"
+ rootok=1
+ ;;
+ live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
+ [ -f "${root#live:}" ] && rootok=1
+ ;;
+ live:nfs*)
+ rootok=1
+ ;;
+esac
+
+[ "$rootok" = "1" ] || return 1
+
+info "root was $liveroot, is now $root"
+
+# make sure that init doesn't complain
+[ -z "$root" ] && root="live"
+
+wait_for_dev -n /dev/root
+
+return 0