X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml2ram;h=0806383316aae8ee541155ce7d8e8681b2131ad3;hb=refs%2Ftags%2Fv2.13.0;hp=16bf33c94b991171389068b7a54a8cd3d08af663;hpb=ce116dcfd5084af6273242e786cc9fda4c24a99c;p=grml-scripts.git diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index 16bf33c..0806383 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Filename: grml2ram # Purpose: copy compressed GRML image to RAM # Authors: (c) Michael Schierl , (c) Michael Prokop @@ -8,7 +8,9 @@ set -e +# shellcheck disable=SC1091 . /etc/grml/lsb-functions +# shellcheck disable=SC1091 . /etc/grml/script-functions check4root || exit 1 @@ -19,12 +21,10 @@ if ! isgrmlcd ; then exit 1 fi -# 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 +# initramfs layout since December 2012, backwards compatibility: +[ -d /lib/live/mount/medium ] && export LIVECD_PATH='/lib/live/mount/medium' +# initramfs layout since December 2018: +[ -d /run/live/medium ] && export LIVECD_PATH='/run/live/medium' if [ -z "$CMDLINE" ]; then # if CMDLINE was set from the outside, we're debugging. @@ -52,7 +52,7 @@ getbootparam(){ MEDIA_PATH="$(getbootparam live-media-path)" MEDIA_PATH="${MEDIA_PATH:-.}" -IMAGE=$(find $LIVECD_PATH/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1) +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' @@ -65,12 +65,13 @@ fi GRMLSIZE="$(du $IMAGE | awk '{print $1}')" RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo) +LOOPDEV=$(/sbin/losetup -j "${IMAGE}" -n -O NAME) 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 + 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 @@ -80,7 +81,7 @@ 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, '