| 1 | Implement resolvconf support
|
| 2 |
|
| 3 | Due to the potential for multiple sources contenting for /etc/resolv.conf
|
| 4 | control, this patch replaces direct file munging with resolvconf indirection.
|
| 5 |
|
| 6 | |
| 7 | |
| 8 | @@ -36,11 +36,11 @@
|
| 9 | # This updated version mostly follows Debian script by Andrew Pollock et al.
|
| 10 | make_resolv_conf() {
|
| 11 | local new_resolv_conf
|
| 12 | + new_resolv_conf=$(mktemp)
|
| 13 |
|
| 14 | # DHCPv4
|
| 15 | if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
|
| 16 | - [ -n "$new_domain_name_servers" ]; then
|
| 17 | - new_resolv_conf=/etc/resolv.conf.dhclient-new
|
| 18 | + [ -n "$new_domain_name_servers" ]; then
|
| 19 | rm -f $new_resolv_conf
|
| 20 |
|
| 21 | if [ -n "$new_domain_name" ]; then
|
| 22 | @@ -70,17 +70,12 @@
|
| 23 | echo nameserver $nameserver >>$new_resolv_conf
|
| 24 | done
|
| 25 | else # keep 'old' nameservers
|
| 26 | - sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
|
| 27 | + resolvconf -l "$interface.dhcp" | sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p >>$new_resolv_conf
|
| 28 | fi
|
| 29 |
|
| 30 | - if [ -f /etc/resolv.conf ]; then
|
| 31 | - chown --reference=/etc/resolv.conf $new_resolv_conf
|
| 32 | - chmod --reference=/etc/resolv.conf $new_resolv_conf
|
| 33 | - fi
|
| 34 | - mv -f $new_resolv_conf /etc/resolv.conf
|
| 35 | + resolvconf -a "$interface.dhpc" <"$new_resolv_conf"
|
| 36 | # DHCPv6
|
| 37 | elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
|
| 38 | - new_resolv_conf=/etc/resolv.conf.dhclient-new
|
| 39 | rm -f $new_resolv_conf
|
| 40 |
|
| 41 | if [ -n "$new_dhcp6_domain_search" ]; then
|
| 42 | @@ -97,14 +92,10 @@
|
| 43 | echo nameserver $nameserver >>$new_resolv_conf
|
| 44 | done
|
| 45 | else # keep 'old' nameservers
|
| 46 | - sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
|
| 47 | + resolvconf -l "$interface.dhcp6" | sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p >>$new_resolv_conf
|
| 48 | fi
|
| 49 |
|
| 50 | - if [ -f /etc/resolv.conf ]; then
|
| 51 | - chown --reference=/etc/resolv.conf $new_resolv_conf
|
| 52 | - chmod --reference=/etc/resolv.conf $new_resolv_conf
|
| 53 | - fi
|
| 54 | - mv -f $new_resolv_conf /etc/resolv.conf
|
| 55 | + resolvconf -a "$interface.dhpc6" <"$new_resolv_conf"
|
| 56 | fi
|
| 57 | }
|
| 58 |
|