X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=components%2F9990-main.sh;h=b0e2a7ba6c56939be875dbaefc75df7fd8df18c9;hb=51f4b9d56200bec4e3e8ca8a209cf84f75308b82;hp=b9bd71b9febc6269f31a4f606d7ae35d181ec63c;hpb=bcf2959a742884070a251e258eebc3f027d8b704;p=live-boot-grml.git diff --git a/components/9990-main.sh b/components/9990-main.sh index b9bd71b..b0e2a7b 100755 --- a/components/9990-main.sh +++ b/components/9990-main.sh @@ -33,11 +33,11 @@ Live () # Needed here too because some things (*cough* udev *cough*) # changes the timeout - if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ] + if [ -n "${NETBOOT}" ] || [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] 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 @@ -121,10 +130,10 @@ Live () 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 @@ -156,16 +165,30 @@ Live () fi fi + if [ -f /etc/hostname ] && ! grep -E -q -v '^[[:space:]]*(#|$)' "${rootmnt}/etc/hostname" + then + log_begin_msg "Copying /etc/hostname to ${rootmnt}/etc/hostname" + cp -v /etc/hostname "${rootmnt}/etc/hostname" + log_end_msg + fi + + if [ -f /etc/hosts ] && ! grep -E -q -v '^[[:space:]]*(#|$|(127.0.0.1|::1|ff02::[12])[[:space:]])' "${rootmnt}/etc/hosts" + then + log_begin_msg "Copying /etc/hosts to ${rootmnt}/etc/hosts" + cp -v /etc/hosts "${rootmnt}/etc/hosts" + log_end_msg + fi + if [ -L /root/etc/resolv.conf ] ; then # assume we have resolvconf DNSFILE="${rootmnt}/etc/resolvconf/resolv.conf.d/base" else DNSFILE="${rootmnt}/etc/resolv.conf" fi - if [ -f /etc/resolv.conf ] && ! grep -E -q -v '^[[:space:]]*#|^[[:space:]]*$' ${DNSFILE} + if [ -f /etc/resolv.conf ] && ! grep -E -q -v '^[[: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 @@ -178,8 +201,8 @@ Live () # 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 + mkdir -p "${rootmnt}/lib/live/mount" + mount --rbind /run/live "${rootmnt}/lib/live/mount" Fstab