Module Name:    src
Committed By:   roy
Date:           Sat Nov 21 07:54:00 UTC 2009

Modified Files:
        src/usr.sbin/dhcp/clientscript: dhclient-script

Log Message:
Use resolvconf(8) to manage /etc/resolv.conf


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/dhcp/clientscript/dhclient-script

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/dhcp/clientscript/dhclient-script
diff -u src/usr.sbin/dhcp/clientscript/dhclient-script:1.12 src/usr.sbin/dhcp/clientscript/dhclient-script:1.13
--- src/usr.sbin/dhcp/clientscript/dhclient-script:1.12	Sun Oct  8 17:09:32 2006
+++ src/usr.sbin/dhcp/clientscript/dhclient-script	Sat Nov 21 07:53:59 2009
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: dhclient-script,v 1.12 2006/10/08 17:09:32 riz Exp $
+# $NetBSD: dhclient-script,v 1.13 2009/11/21 07:53:59 roy Exp $
 
 ENTERHOOKS=/etc/dhclient-enter-hooks
 EXITHOOKS=/etc/dhclient-exit-hooks
@@ -8,34 +8,39 @@
 SIGNATURE="# Created by dhclient from"
 INTSIG="$SIGNATURE $interface"
 
+echo_resolv_conf() {
+	echo "$INTSIG"
+	echo search $new_domain_name
+	for nameserver in $new_domain_name_servers; do
+		echo nameserver $nameserver
+	done
+}
+
 make_resolv_conf() {
 	if [ ! -z "$new_domain_name_servers" ]; then
-		if [ -f $RESOLV ]
-		then
-			while read line; do
-				case $line in
-				"$SIGNATURE"*)
-					;;
-				*)
-					mv $RESOLV $RESOLV.save;;
-				esac
-				break
-			done < $RESOLV
-		fi
-		echo "$INTSIG" > $RESOLV
-		if [ ! -z "$new_domain_name" ]
-		then
-			echo search $new_domain_name >> $RESOLV
+		if [ -x /sbin/resolvconf ]; then
+			echo_resolv_conf | /sbin/resolvconf -a $interface
+		else
+			if [ -f $RESOLV ]; then
+				while read line; do
+					case $line in
+					"$SIGNATURE"*)
+						;;
+					*)
+						mv $RESOLV $RESOLV.save;;
+					esac
+					break
+				done < $RESOLV
+			fi
+			echo_resolv_conf > $RESOLV
 		fi
-		for nameserver in $new_domain_name_servers; do
-			echo nameserver $nameserver
-		done >> $RESOLV
 	fi
 }
 
 restore_resolv_conf() {
-	if [ -f $RESOLV.save -a -f $RESOLV ]
-	then
+	if [ -x /sbin/resolvconf ]; then
+		/sbin/resolvconf -d $interface
+	elif [ -f $RESOLV.save -a -f $RESOLV ]; then
 		while read line; do
 			case $line in
 			"$INTSIG"*)

Reply via email to