X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=components%2F9990-main.sh;h=4ea8ee118c7c373fde02fc6668df420fcff2e707;hb=07d13d4a81e8e3ea3f7cff63a6528efd5a46b1e7;hp=20e8c0c9590584a363a05419585c4a7dcb3e5125;hpb=0d878d3a679820d570a20c0fa1c1a2c5b92ad037;p=live-boot-grml.git diff --git a/components/9990-main.sh b/components/9990-main.sh index 20e8c0c..4ea8ee1 100755 --- a/components/9990-main.sh +++ b/components/9990-main.sh @@ -37,7 +37,7 @@ Live () then if do_netmount then - livefs_root="${mountpoint}" + livefs_root="${mountpoint?}" else panic "Unable to find a live file system on the network" fi @@ -52,13 +52,22 @@ Live () else if [ -x /usr/bin/memdiskfind ] then - MEMDISK=$(/usr/bin/memdiskfind) - - if [ $? -eq 0 ] + if ! MEMDISK=$(/usr/bin/memdiskfind) then # We found a memdisk, set up phram - modprobe phram phram=memdisk,${MEMDISK} - modprobe phram phram=memdisk,${MEMDISK} + # Sometimes "modprobe phram" can not successfully create /dev/mtd0. + # Have to try several times. + max_try=20 + while [ ! -c /dev/mtd0 ] && [ "$max_try" -gt 0 ]; do + modprobe phram "phram=memdisk,${MEMDISK}" + sleep 0.2 + if [ -c /dev/mtd0 ]; then + break + else + rmmod phram + fi + max_try=$((max_try - 1)) + done # Load mtdblock, the memdisk will be /dev/mtdblock0 modprobe mtdblock @@ -77,7 +86,7 @@ Live () fi sleep 1 - i="$(($i + 1))" + i=$((i + 1)) done fi fi @@ -111,20 +120,20 @@ Live () then losetup -d /dev/loop0 - if is_mountpoint /live/fromiso + if is_mountpoint /run/live/fromiso then - umount /live/fromiso - rmdir --ignore-fail-on-non-empty /live/fromiso \ + umount /run/live/fromiso + rmdir --ignore-fail-on-non-empty /run/live/fromiso \ >/dev/null 2>&1 || true fi fi if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ] then - setup_unionfs "${livefs_root}" "${rootmnt}" + setup_unionfs "${livefs_root}" "${rootmnt?}" else mac="$(get_mac)" - mac="$(echo ${mac} | sed 's/-//g')" + mac="$(echo "${mac}" | sed 's/-//g')" mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}" fi @@ -162,10 +171,10 @@ Live () else DNSFILE="${rootmnt}/etc/resolv.conf" fi - if [ -f /etc/resolv.conf ] && [ ! -s ${DNSFILE} ] + if [ -f /etc/resolv.conf ] && ! grep -E -q -v '^[[:space:]]*#|^[[:space:]]*$' "${DNSFILE}" then log_begin_msg "Copying /etc/resolv.conf to ${DNSFILE}" - cp -v /etc/resolv.conf ${DNSFILE} + cp -v /etc/resolv.conf "${DNSFILE}" log_end_msg fi @@ -174,6 +183,13 @@ Live () panic "A wrong rootfs was mounted." fi + # avoid breaking existing user scripts that rely on the old path + # this includes code that checks what is mounted on /lib/live/mount/* + # (eg: grep /lib/live /proc/mount) + # XXX: to be removed before the bullseye release + mkdir -p "${rootmnt}/lib/live/mount" + mount --rbind /run/live "${rootmnt}/lib/live/mount" + Fstab Netbase @@ -182,5 +198,7 @@ Live () exec 1>&6 6>&- exec 2>&7 7>&- kill ${tailpid} - [ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && cp boot.log "${rootmnt}/var/log/live" 2>/dev/null + [ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && ( \ + cp boot.log "${rootmnt}/var/log/live" 2>/dev/null; \ + cp fsck.log "${rootmnt}/var/log/live" 2>/dev/null ) }