#!/bin/sh # Filename: grml2ram # Purpose: copy compressed GRML image to RAM # 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 . /etc/grml/lsb-functions . /etc/grml/script-functions check4root || exit 1 check4progs rsync gawk || exit 2 if ! isgrmlcd ; then eerror "Not running grml in live-cd mode. Nothing to be done, exiting." ; eend 1 exit 1 fi IMAGE=$(ls /live/image/live/*.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 $IMAGE | awk '{print $1}')" RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo) case "$*" in -f|--force) ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0 ;; *) if test $RAM -lt $GRMLSIZE ; then eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1 exit 1 fi ;; esac 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, '