X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml2ram;fp=usr_sbin%2Fgrml2ram;h=05b0ceae688da8d47b2499d2b2a991822da1424b;hb=4c7a73cd5b64a1f2af850a785ba8babc9678d4fd;hp=dd038d278ab5e9f36e654f65be2fa33267e1ce46;hpb=301597ea695b5a62b9a26f3d7e065c43118a7678;p=grml-scripts.git diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index dd038d2..05b0cea 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -19,7 +19,34 @@ if ! isgrmlcd ; then exit 1 fi -IMAGE=$(ls /live/image/live/*.squashfs 2>/dev/null | head -1) +if [ -z "$CMDLINE" ]; then + # if CMDLINE was set from the outside, we're debugging. + # otherwise, take CMDLINE from Kernel and config files. + CMDLINE="$(cat /proc/cmdline)" + [ -d /cdrom/bootparams/ ] && CMDLINE="$CMDLINE $(cat /cdrom/bootparams/* | tr '\n' ' ')" + [ -d /live/image/bootparams/ ] && CMDLINE="$CMDLINE $(cat /live/image/bootparams/* | tr '\n' ' ')" +fi + +getbootparam(){ + local line + local ws + ws=' ' + line=" $CMDLINE " + case "$line" in + *[${ws}]"$1="*) + result="${line##*[$ws]$1=}" + result="${result%%[$ws]*}" + echo "$result" + return 0 ;; + *) # no match? + return 1 ;; + esac +} + +MEDIA_PATH="$(getbootparam live-media-path)" +MEDIA_PATH="${MEDIA_PATH:-.}" + +IMAGE=$(find /live/image/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1) if ! [ -r "$IMAGE" ] ; then if [ -r /cdrom/GRML/GRML ] ; then IMAGE='/cdrom/GRML/GRML' @@ -49,7 +76,7 @@ rsync -a --progress $IMAGE /tmp/GRML LANGUAGE=C LANG=C LC_ALL=C perl << EOF open LOOP, '