3 # Purpose: copy compressed GRML image to RAM
4 # Authors: (c) Michael Schierl <schierlm-public@gmx.de>, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Son Sep 30 16:04:17 CEST 2007 [mika]
8 ################################################################################
12 . /etc/grml/lsb-functions
13 . /etc/grml/script-functions
16 check4progs rsync gawk || exit 2
19 eerror "Not running grml in live-cd mode. Nothing to be done, exiting." ; eend 1
23 IMAGE=$(ls /live/image/live/*.squashfs 2>/dev/null | head -1)
24 if ! [ -r "$IMAGE" ] ; then
25 if [ -r /cdrom/GRML/GRML ] ; then
26 IMAGE='/cdrom/GRML/GRML'
28 eerror "Can not access grml squashfs file."
29 eerror "Looks like you did run grml2ram already?" ; eend 1
34 GRMLSIZE="$(du $IMAGE | awk '{print $1}')"
35 RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo)
37 case "$*" in -f|--force)
38 ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0
41 if test $RAM -lt $GRMLSIZE ; then
42 eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1
48 einfo "Copying $IMAGE to RAM, this might take a while."
49 rsync -a --progress $IMAGE /tmp/GRML
50 LANGUAGE=C LANG=C LC_ALL=C perl << EOF
51 open LOOP, '</dev/loop0' or die $!;
52 open DEST, '</tmp/GRML' or die $!;
53 ioctl(LOOP, 0x4C06, fileno(DEST)) or die $!
59 GRMLDEV=$(awk '{if ($2 ~ /^\/live\/image$/ ) print $1}' /etc/mtab)
60 if [ -z "$GRMLDEV" ]; then
61 GRMLDEV=$(awk '{if ($2 ~ /^\/cdrom$/ ) print $1}' /etc/mtab)
63 [ -n "$GRMLDEV" ] || GRMLDEV='/dev/cdrom'
65 einfo "Unmounting cdrom"
66 [ -d /live/image ] && umount /live/image || umount /cdrom
68 einfo "Now you can eject your grml-cd (e.g. run 'eject $GRMLDEV')." ; eend 0
70 ## END OF FILE #################################################################