From: Raphaƫl Hertzog Date: Fri, 6 Sep 2019 06:41:36 +0000 (+0000) Subject: Merge branch 'master' into 'master' X-Git-Tag: debian/1%20210122~14 X-Git-Url: http://git.grml.org/?a=commitdiff_plain;h=b5e8d802f3ffb340e5118b530f1256deb22bb35a;hp=abfb0596ba63f83a511f797b668b1ecf5de8fca6;p=live-boot-grml.git Merge branch 'master' into 'master' Fix DNS search entry in /etc/resolv.conf and copy /etc/hostname and /etc/hosts into target See merge request live-team/live-boot!19 --- diff --git a/components/9990-main.sh b/components/9990-main.sh index 530cd3b..4a22909 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,16 +52,14 @@ 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 # Sometimes "modprobe phram" can not successfully create /dev/mtd0. # Have to try several times. max_try=20 - while [ ! -c /dev/mtd0 -a "$max_try" -gt 0 ]; do - modprobe phram phram=memdisk,${MEMDISK} + while [ ! -c /dev/mtd0 ] && [ "$max_try" -gt 0 ]; do + modprobe phram "phram=memdisk,${MEMDISK}" sleep 0.2 if [ -c /dev/mtd0 ]; then break @@ -88,7 +86,7 @@ Live () fi sleep 1 - i="$(($i + 1))" + i=$((i + 1)) done fi fi @@ -132,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 @@ -167,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 @@ -189,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 Netbase diff --git a/components/9990-networking.sh b/components/9990-networking.sh index 9cc3674..92c66ee 100755 --- a/components/9990-networking.sh +++ b/components/9990-networking.sh @@ -128,9 +128,17 @@ do_netsetup () if [ -n "${interface}" ] then + # HWADDR used by do_iscsi from 9990-mount-iscsi.sh + # shellcheck disable=SC2034 HWADDR="$(cat "/sys/class/net/${interface}/address")" fi + if [ ! -e "/etc/hostname" ] && [ -n "${HOSTNAME}" ] + then + echo "Creating /etc/hostname" + echo "${HOSTNAME}" > /etc/hostname + fi + # Only create /etc/hosts if FQDN is known (to let 'hostname -f' query # this file). Otherwise DNS will be queried to determine the FQDN. if [ ! -e "/etc/hosts" ] && [ -n "${DNSDOMAIN}" ] @@ -154,7 +162,6 @@ EOF if [ -n "${DNSDOMAIN}" ] then echo "domain ${DNSDOMAIN}" > /etc/resolv.conf - echo "search ${DNSDOMAIN}" >> /etc/resolv.conf fi for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} ${DNSSERVERS} @@ -164,6 +171,14 @@ EOF echo "nameserver $i" >> /etc/resolv.conf fi done + + if [ -n "${DOMAINSEARCH}" ] + then + echo "search ${DOMAINSEARCH}" >> /etc/resolv.conf + elif [ -n "${DNSDOMAIN}" ] + then + echo "search ${DNSDOMAIN}" >> /etc/resolv.conf + fi fi # Check if we have a network device at all