1 From 5fff70167b23195380c1e18dd9ac785641ab9f3e Mon Sep 17 00:00:00 2001
2 From: Evgeni Golov <evgeni@grml.org>
3 Date: Tue, 25 Mar 2014 08:38:58 +0100
4 Subject: [PATCH 2/2] support resolvconf in the squashfs
6 when resolvconf is used in the squashfs, /etc/resolv.conf is a symlink
7 to the generated version. depending on the size of the squashfs, the
8 moon phase and the charge of the flux capacitor, we sometimes try to
9 write to /etc/resolv.conf while it still points to nirvana, as resolvconf
10 did not generate it yet.
12 instead of being racy and writing to a file which will be regenerated
13 anyways, let's detect resolvconf and write to its base file instead.
15 initial detection idea by Mika Prokop <mika@grml.org>
17 components/9990-main.sh | 12 +++++++++---
18 components/9990-netbase.sh | 15 ++++++++++-----
19 2 files changed, 19 insertions(+), 8 deletions(-)
21 diff --git a/components/9990-main.sh b/components/9990-main.sh
22 index 83f087f..85b8a1d 100755
23 --- a/components/9990-main.sh
24 +++ b/components/9990-main.sh
25 @@ -178,10 +178,16 @@ Live ()
29 - if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
30 + if [ -L /root/etc/resolv.conf ] ; then
31 + # assume we have resolvconf
32 + DNSFILE="${rootmnt}/etc/resolvconf/resolv.conf.d/base"
34 + DNSFILE="${rootmnt}/etc/resolv.conf"
36 + if [ -f /etc/resolv.conf ] && [ ! -s ${DNSFILE} ]
38 - log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
39 - cp -v /etc/resolv.conf ${rootmnt}/etc/resolv.conf
40 + log_begin_msg "Copying /etc/resolv.conf to ${DNSFILE}"
41 + cp -v /etc/resolv.conf ${DNSFILE}
45 diff --git a/components/9990-netbase.sh b/components/9990-netbase.sh
46 index af3522f..a32a47b 100755
47 --- a/components/9990-netbase.sh
48 +++ b/components/9990-netbase.sh
49 @@ -16,7 +16,12 @@ Netbase ()
50 log_begin_msg "Preconfiguring networking"
52 IFFILE="/root/etc/network/interfaces"
53 - DNSFILE="/root/etc/resolv.conf"
54 + if [ -L /root/etc/resolv.conf ] ; then
55 + # assume we have resolvconf
56 + DNSFILE="/root/etc/resolvconf/resolv.conf.d/base"
58 + DNSFILE="/root/etc/resolv.conf"
61 if [ "${STATICIP}" = "frommedia" ] && [ -e "${IFFILE}" ]
63 @@ -102,7 +107,7 @@ EOF
67 - if [ ! -f /root/etc/resolv.conf ] || [ -z "$(cat /root/etc/resolv.conf)" ]
68 + if [ ! -f "${DNSFILE}" ] || [ -z "$(cat ${DNSFILE})" ]
70 if [ -f /netboot.config ]
72 @@ -112,7 +117,7 @@ EOF
73 rc_search=$(cat netboot.config | awk '/domain/ { print $3 }')
74 rc_server0="$(cat netboot.config | awk '/dns0/ { print $5 }')"
76 -cat > /root/etc/resolv.conf << EOF
77 +cat > $DNSFILE << EOF
80 nameserver ${rc_server0}
81 @@ -122,10 +127,10 @@ EOF
83 if [ "${rc_server1}" != "0.0.0.0" ]
85 - echo "nameserver ${rc_server1}" >> /root/etc/resolv.conf
86 + echo "nameserver ${rc_server1}" >> $DNSFILE
89 - cat /root/etc/resolv.conf >> /root/var/log/netboot.config
90 + cat $DNSFILE >> /root/var/log/netboot.config