Lines 11-78
Link Here
|
11 |
fi |
11 |
fi |
12 |
|
12 |
|
13 |
make_resolv_conf() { |
13 |
make_resolv_conf() { |
|
|
14 |
if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then |
15 |
return 0 |
16 |
fi |
17 |
local conf= |
14 |
if [ x"$new_domain_name_servers" != x ]; then |
18 |
if [ x"$new_domain_name_servers" != x ]; then |
15 |
( cat /dev/null > /etc/resolv.conf.dhclient ) |
19 |
if [ "x$new_domain_search" != x ]; then |
16 |
exit_status=$? |
20 |
conf="${conf}search ${new_domain_search}\n" |
17 |
if [ $exit_status -ne 0 ]; then |
21 |
elif [ "x$new_domain_name" != x ]; then |
18 |
$LOGGER "Unable to create /etc/resolv.conf.dhclient: Error $exit_status" |
22 |
# Note that the DHCP 'Domain Name Option' is really just a domain |
19 |
else |
23 |
# name, and that this practice of using the domain name option as |
20 |
if [ "x$new_domain_search" != x ]; then |
24 |
# a search path is both nonstandard and deprecated. |
21 |
( echo search $new_domain_search >> /etc/resolv.conf.dhclient ) |
25 |
conf="${conf}search ${new_domain_name}\n" |
22 |
exit_status=$? |
|
|
23 |
elif [ "x$new_domain_name" != x ]; then |
24 |
# Note that the DHCP 'Domain Name Option' is really just a domain |
25 |
# name, and that this practice of using the domain name option as |
26 |
# a search path is both nonstandard and deprecated. |
27 |
( echo search $new_domain_name >> /etc/resolv.conf.dhclient ) |
28 |
exit_status=$? |
29 |
fi |
30 |
for nameserver in $new_domain_name_servers; do |
31 |
if [ $exit_status -ne 0 ]; then |
32 |
break |
33 |
fi |
34 |
( echo nameserver $nameserver >>/etc/resolv.conf.dhclient ) |
35 |
exit_status=$? |
36 |
done |
37 |
|
38 |
# If there were no errors, attempt to mv the new file into place. |
39 |
if [ $exit_status -eq 0 ]; then |
40 |
( mv /etc/resolv.conf.dhclient /etc/resolv.conf ) |
41 |
exit_status=$? |
42 |
fi |
43 |
|
44 |
if [ $exit_status -ne 0 ]; then |
45 |
$LOGGER "Error while writing new /etc/resolv.conf." |
46 |
fi |
47 |
fi |
26 |
fi |
|
|
27 |
for nameserver in $new_domain_name_servers; do |
28 |
conf="${conf}nameserver ${nameserver}\n" |
29 |
done |
48 |
elif [ "x${new_dhcp6_name_servers}" != x ] ; then |
30 |
elif [ "x${new_dhcp6_name_servers}" != x ] ; then |
49 |
( cat /dev/null > /etc/resolv.conf.dhclient6 ) |
31 |
if [ "x${new_dhcp6_domain_search}" != x ] ; then |
50 |
exit_status=$? |
32 |
conf="${conf}search ${new_dhcp6_domain_search}\n" |
51 |
if [ $exit_status -ne 0 ] ; then |
33 |
fi |
52 |
$LOGGER "Unable to create /etc/resolv.conf.dhclient6: Error $exit_status" |
34 |
for nameserver in ${new_dhcp6_name_servers} ; do |
53 |
else |
35 |
conf="${conf}nameserver ${nameserver}\n" |
54 |
if [ "x${new_dhcp6_domain_search}" != x ] ; then |
36 |
done |
55 |
( echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 ) |
37 |
fi |
56 |
exit_status=$? |
|
|
57 |
fi |
58 |
for nameserver in ${new_dhcp6_name_servers} ; do |
59 |
if [ $exit_status -ne 0 ] ; then |
60 |
break |
61 |
fi |
62 |
( echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 ) |
63 |
exit_status=$? |
64 |
done |
65 |
|
66 |
if [ $exit_status -eq 0 ] ; then |
67 |
( mv /etc/resolv.conf.dhclient6 /etc/resolv.conf ) |
68 |
exit_status=$? |
69 |
fi |
70 |
|
38 |
|
71 |
if [ $exit_status -ne 0 ] ; then |
39 |
if [ x"$conf" != x ]; then |
72 |
$LOGGER "Error while writing new /etc/resolv.conf." |
40 |
conf="# Generated by dhclient or interface $interface\n${conf}" |
73 |
fi |
41 |
if type resolvconf >/dev/null 2>&1; then |
|
|
42 |
printf "${conf}" | resolvconf -a $interface |
43 |
else |
44 |
printf "${conf}" > /etc/resolv.conf |
45 |
chmod 644 /etc/resolv.conf |
74 |
fi |
46 |
fi |
75 |
fi |
47 |
fi |
|
|
48 |
|
76 |
# If we're making confs, may as well make an ntp.conf too |
49 |
# If we're making confs, may as well make an ntp.conf too |
77 |
make_ntp_conf |
50 |
make_ntp_conf |
78 |
} |
51 |
} |