If you have set up a machine to use rebound(8), then boot the install
media to perform an upgrade, you won't be able to fetch the sets
over the network because there is no nameserver in resolv.conf and
rebound isn't running.

The diff below adds the nameserver from rebound.conf to the ramdisk's
resolv.conf if no other nameserver has been configured.

All the code is from rpe@.  I just moved the main chunk to the end
of enable_network() so it is executed after dhclient.  rpe@ wrote
this before the recent unpriv changes, but it still works.

It works for me...

Index: distrib/miniroot/install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.912
diff -u -p -r1.912 install.sub
--- distrib/miniroot/install.sub        4 Sep 2016 12:36:33 -0000       1.912
+++ distrib/miniroot/install.sub        8 Sep 2016 11:39:44 -0000
@@ -2081,7 +2081,7 @@ ifstart () {
 
 # Configure the network during upgrade based on the on-disk configuration.
 enable_network() {
-       local _f _gw _trunks _svlans _vlans
+       local _f _gw _ip _ns _no_ns=1 _only_lh=1 _rest _trunks _svlans _vlans
 
        # Copy any network configuration files. N.B.: hosts already copied.
        for _f in dhclient.conf resolv.conf resolv.conf.tail; do
@@ -2134,6 +2134,23 @@ enable_network() {
        done
 
        route -qn add -net 127 127.0.0.1 -reject >/dev/null
+
+       # If resolv.conf does not have a nameserver config, or only one for
+       # localhost, add the nameserver from rebound.conf if that file exists.
+       if [[ -s /etc/resolv.conf ]]; then
+               while read _ns _ip _rest; do
+                       [[ $_ns == nameserver ]] && _no_ns=0 || continue
+                       [[ $_ip != @(127.0.0.1|localhost) ]] && _only_lh=0
+               done </etc/resolv.conf
+               if _ns=$(stripcom /mnt/etc/rebound.conf) && [[ -n $_ns ]]; then
+                       if ((_no_ns)); then
+                               print "nameserver $_ns" >>/etc/resolv.conf
+                       elif ((_only_lh)); then
+                               sed -i "s/^nameserver.*$/nameserver $_ns/" \
+                                       /etc/resolv.conf
+                       fi
+               fi
+       fi
 }
 
 # Fetch the list of mirror servers and installer choices from previous runs if
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to