X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml2ram;h=16bf33c94b991171389068b7a54a8cd3d08af663;hb=ce116dcfd5084af6273242e786cc9fda4c24a99c;hp=b0ba4e6b7bca0755bd732bfb53d307cb52a5209f;hpb=c919caade70432b18719ca1637c91db10e2744f9;p=grml-scripts.git diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index b0ba4e6..16bf33c 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -4,7 +4,6 @@ # Authors: (c) Michael Schierl , (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Son Sep 30 16:04:17 CEST 2007 [mika] ################################################################################ set -e @@ -20,7 +19,40 @@ if ! isgrmlcd ; then exit 1 fi -IMAGE=$(ls /live/image/live/*.squashfs 2>/dev/null | head -1) +# old linuxrc version: +[ -d /cdrom ] && export LIVECD_PATH=/cdrom +# initramfs layout until around December 2012: +[ -d /live/image ] && export LIVECD_PATH=/live/image +# initramfs layout since around December 2012: +[ -d /lib/live/mount/medium ] && export LIVECD_PATH=/lib/live/mount/medium + +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 ${LIVECD_PATH}/bootparams/ ] && CMDLINE="$CMDLINE $(cat ${LIVECD_PATH}/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 $LIVECD_PATH/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1) if ! [ -r "$IMAGE" ] ; then if [ -r /cdrom/GRML/GRML ] ; then IMAGE='/cdrom/GRML/GRML' @@ -50,14 +82,24 @@ rsync -a --progress $IMAGE /tmp/GRML LANGUAGE=C LANG=C LC_ALL=C perl << EOF open LOOP, '