Subject: /etc/ifconfig.foo enhancement
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 01/11/2001 19:44:05
	the attached patch will allow two things in /etc/ifconfig.*:
	- allow comments started by "#"
	- allow command invocation started by "!"

	what is good about these?  comment is obvious.  "!" is good
	as it will get invoked only when you have particular interface on
	the system.  so, for example, if you use two pcmcia cards (like wi0
	or an0) time to time, you can do something like this, and only either
	of them (for the currently-inserted card) will get used:

	ifconfig.wi0:
		up
		# autoconfigure IPv4
		!dhclient $int
		# autoconfigure IPv6
		!rtsol $int

	ifconfig.an0:
		up
		media auto
		# setup IPv4 manually
		inet 10.1.1.1
		# autoconfigure IPv6
		!rtsol $int

	do people think it worth a commit, or do people think it too much?

	(inspired by openbsd /etc/hostname.foo)

itojun



Index: rc.d/network
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.d/network,v
retrieving revision 1.28
diff -u -r1.28 network
--- rc.d/network	2001/01/03 17:54:05	1.28
+++ rc.d/network	2001/01/11 09:49:22
@@ -110,7 +110,16 @@
 				echo -n " $int"
 				while read args; do
 					[ -z "$args" ] && continue
-					ifconfig $int $args
+					case "$args" in
+					"#"*)
+						;;
+					"!"*)
+						eval ${args#*!}
+						;;
+					*)
+						ifconfig $int $args
+						;;
+					esac
 				done < /etc/ifconfig.$int
 			else
 				if ! checkyesno auto_ifconfig; then