linamh/net-misc/dhcp/files/dhcp-3.0.3-dhclient-resolvconf.patch

192 lines
6.5 KiB
Diff
Raw Normal View History

--- client/scripts/bsdos
+++ client/scripts/bsdos
@@ -1,11 +1,22 @@
#!/bin/sh
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- echo search $new_domain_name >/etc/resolv.conf
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf
- done
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ "x$new_domain_name" != x ]; then
+ conf="${conf}search $new_domain_name\n"
+ fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver $nameserver\n"
+ done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
+ fi
fi
# If we're making confs, may as well make an ntp.conf too
make_ntp_conf
--- client/scripts/freebsd
+++ client/scripts/freebsd
@@ -11,25 +11,21 @@
fi
make_resolv_conf() {
- if [ x"$new_domain_name_servers" != x ]; then
- if [ "x$new_domain_name" != x ]; then
- ( echo search $new_domain_name >/etc/resolv.conf )
- exit_status=$?
- else
- if [ -e /etc/resolv.conf ] ; then
- ( rm /etc/resolv.conf )
- exit_status=$?
- else
- ( touch /etc/resolv.conf )
- exit_status=$?
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ "x$new_domain_name" != x ]; then
+ conf="${conf}search $new_domain_name\n"
fi
- fi
- if [ $exit_status -ne 0 ]; then
- $LOGGER "WARNING: Unable to update resolv.conf: Error $exit_status"
- else
for nameserver in $new_domain_name_servers; do
- ( echo nameserver $nameserver >>/etc/resolv.conf )
+ conf="${conf}nameserver $nameserver\n"
done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
fi
fi
# If we're making confs, may as well make an ntp.conf too
--- client/scripts/linux
+++ client/scripts/linux
@@ -23,12 +23,22 @@
# of the $1 in its args.
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- echo search $new_domain_name >/etc/resolv.conf
- chmod 644 /etc/resolv.conf
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf
- done
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ "x$new_domain_name" != x ]; then
+ conf="${conf}search $new_domain_name\n"
+ fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver $nameserver\n"
+ done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
+ fi
fi
# If we're making confs, may as well make an ntp.conf too
make_ntp_conf
--- client/scripts/netbsd
+++ client/scripts/netbsd
@@ -1,11 +1,22 @@
#!/bin/sh
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- echo search $new_domain_name >/etc/resolv.conf
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf
- done
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ "x$new_domain_name" != x ]; then
+ conf="${conf}search $new_domain_name\n"
+ fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver $nameserver\n"
+ done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
+ fi
fi
# If we're making confs, may as well make an ntp.conf too
make_ntp_conf
--- client/scripts/openbsd
+++ client/scripts/openbsd
@@ -1,11 +1,22 @@
#!/bin/sh
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- echo search $new_domain_name >/etc/resolv.conf
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf
- done
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ x$new_domain_name != x ]; then
+ conf="${conf}search $new_domain_name\n"
+ fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver $nameserver\n"
+ done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
+ fi
fi
# If we're making confs, may as well make an ntp.conf too
make_ntp_conf
--- client/scripts/solaris
+++ client/scripts/solaris
@@ -1,11 +1,22 @@
#!/bin/sh
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- echo search $new_domain_name >/etc/resolv.conf
- for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf
- done
+ if [ x$PEER_DNS = x ] || [ x$PEER_DNS = xyes ]; then
+ if [ "x$new_domain_name" != x ] || [ "x$new_domain_name_servers" != x ]; then
+ conf="# Generated by dhclient for interface $interface\n"
+ if [ "x$new_domain_name" != x ]; then
+ conf="${conf}search $new_domain_name\n"
+ fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver $nameserver\n"
+ done
+ if [ -x /sbin/resolvconf ]; then
+ printf "$conf" | resolvconf -a "$interface"
+ else
+ printf "$conf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
+ fi
fi
# If we're making confs, may as well make an ntp.conf too
make_ntp_conf