cvs commit: src/etc pccard_ether

Brooks Davis brooks at one-eyed-alien.net
Thu Sep 29 13:51:30 PDT 2005


On Thu, Sep 29, 2005 at 02:45:25PM +0900, Hajimu UMEMOTO wrote:
> Hi,
> 
> >>>>> On Wed, 28 Sep 2005 15:05:49 -0700
> >>>>> Brooks Davis <brooks at one-eyed-alien.net> said:
> 
> brooks> How would you feel about a forcestart option as a compromise for now?
> brooks> That would override both the AUTO check and the up check.
> 
> Yes, I'll be happy with your offer.

Here's a lightly tested implementation based on rc.subr.  It adds
support for the force prefix to start and stop as well as a new restart
option.  It seems to work in limited testing.

-- Brooks

Index: pccard_ether
===================================================================
RCS file: /home/ncvs/src/etc/pccard_ether,v
retrieving revision 1.47
diff -u -p -r1.47 pccard_ether
--- pccard_ether	28 Sep 2005 19:59:18 -0000	1.47
+++ pccard_ether	29 Sep 2005 20:36:48 -0000
@@ -2,7 +2,7 @@
 #
 # $FreeBSD: src/etc/pccard_ether,v 1.47 2005/09/28 19:59:18 brooks Exp $
 #
-# pccard_ether interfacename [start|stop]
+# pccard_ether interfacename [start|stop|restart]
 #
 # example: pccard_ether fxp0 start
 #
@@ -10,10 +10,13 @@
 . /etc/rc.subr
 . /etc/network.subr
 
-usage()
-{
-	err 3 'USAGE: $0 interface (start|stop)'
-}
+name="pccard_ether"
+start_precmd="checkauto"
+start_cmd="pccard_ether_start"
+stop_precmd="checkauto"
+stop_cmd="pccard_ether_stop"
+restart_precmd="checkauto"
+restart_cmd="pccard_ether_restart"
 
 setup_routes()
 {
@@ -54,23 +57,17 @@ remove_routes()
 	fi
 }
 
-ifn=$1
-shift
-startstop=$1
-shift
-
-load_rc_config pccard_ether
-
-# Ignore interfaces with the NOAUTO keyword
-autoif $ifn || exit 0
-
-if [ -n "$1" ]; then
-	usage
-fi
+checkauto()
+{
+	if [ -z "$rc_force" ]; then
+		# Ignore interfaces with the NOAUTO keyword
+		autoif $ifn || exit 0
+	fi
+}
 
-case ${startstop} in
-[Ss][Tt][Aa][Rr][Tt] | '')
-	if [ -x /usr/bin/grep ]; then
+pccard_ether_start()
+{
+	if [ -z "$rc_force" -a -x /usr/bin/grep ]; then
 		if ifconfig $ifn | grep -s '[<,]UP[,>]' > /dev/null 2>&1; then
 		    # Interface is already up, so ignore it.
 		    exit 0
@@ -91,10 +88,10 @@ case ${startstop} in
 	if checkyesno ipv6_enable; then
 		network6_interface_setup $ifn
 	fi
-	;;
+}
 
-# Stop the interface
-[Ss][Tt][Oo][Pp])
+pccard_ether_stop()
+{
 	if [ -n "`ifconfig_getargs $ifn`" ]; then
 		if ! dhcpif $ifn; then
 			remove_routes
@@ -110,7 +107,24 @@ case ${startstop} in
 	if checkyesno removable_route_flush; then
 		route -n flush -inet > /dev/null
 	fi
-	;;
-*)
-	usage
-esac
+}
+
+pccard_ether_restart()
+{
+	# Hand implemented because the default implementation runs
+	# the equivalent of "$0 start; $0 stop" and this script
+	# doesn't support that syntax
+	pccard_ether_stop
+	pccard_ether_start
+}
+
+ifn=$1
+shift
+if [ -z "$*" ]; then
+	args="start"
+else
+	args=$*
+fi
+
+load_rc_config pccard_ether
+run_rc_command $args

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-all/attachments/20050929/18f8bb82/attachment.bin


More information about the cvs-all mailing list