X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml2ram;h=05b0ceae688da8d47b2499d2b2a991822da1424b;hb=0c2ca6d03c11580038978c3bcd7eba02d788bac2;hp=bbd4bd69f2488449cb05ae78b424e40c74bc2389;hpb=58ccd74023808d32b15ebe87d741d79e0be405d0;p=grml-scripts.git diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index bbd4bd6..05b0cea 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -1,10 +1,9 @@ #!/bin/sh # Filename: grml2ram # Purpose: copy compressed GRML image to RAM -# Authors: grml-team (grml.org), (c) Michael Schierl , (c) Michael Prokop +# 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: Die Dez 12 19:55:05 CET 2006 [mika] ################################################################################ set -e @@ -20,12 +19,45 @@ if ! isgrmlcd ; then exit 1 fi -if ! [ -r /cdrom/GRML/GRML ] ; then - eerror "Can not access /cdrom/GRML/GRML. Looks like you did run grml2ram already?" ; eend 1 - exit 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' + else + eerror "Can not access grml squashfs file." + eerror "Looks like you did run grml2ram already?" ; eend 1 + exit 1 + fi fi -GRMLSIZE=$(du /cdrom/GRML/GRML | awk '{print $1}') +GRMLSIZE="$(du $IMAGE | awk '{print $1}')" RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo) case "$*" in -f|--force) @@ -39,18 +71,26 @@ case "$*" in -f|--force) ;; esac -einfo "Copying /cdrom/GRML/GRML to RAM, this might take a while." -rsync -a --progress /cdrom/GRML/GRML /tmp/GRML +einfo "Copying $IMAGE to RAM, this might take a while." +rsync -a --progress $IMAGE /tmp/GRML LANGUAGE=C LANG=C LC_ALL=C perl << EOF open LOOP, '