Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Sep 2005 13:51:28 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Hajimu UMEMOTO <ume@FreeBSD.org>
Cc:        Brooks Davis <brooks@one-eyed-alien.net>, cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/etc pccard_ether
Message-ID:  <20050929205128.GA18164@odin.ac.hmc.edu>
In-Reply-To: <yge4q844ebu.wl%ume@mahoroba.org>
References:  <200509281959.j8SJxIpD046472@repoman.freebsd.org> <ygey85hgdgh.wl%ume@mahoroba.org> <20050928201431.GA18560@odin.ac.hmc.edu> <ygewtl1gcom.wl%ume@mahoroba.org> <20050928204145.GA20866@odin.ac.hmc.edu> <ygevf0khpb3.wl%ume@mahoroba.org> <20050928220549.GA28378@odin.ac.hmc.edu> <yge4q844ebu.wl%ume@mahoroba.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Sep 29, 2005 at 02:45:25PM +0900, Hajimu UMEMOTO wrote:
> Hi,
>=20
> >>>>> On Wed, 28 Sep 2005 15:05:49 -0700
> >>>>> Brooks Davis <brooks@one-eyed-alien.net> said:
>=20
> 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.
>=20
> 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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
=20
-usage()
-{
-	err 3 'USAGE: $0 interface (start|stop)'
-}
+name=3D"pccard_ether"
+start_precmd=3D"checkauto"
+start_cmd=3D"pccard_ether_start"
+stop_precmd=3D"checkauto"
+stop_cmd=3D"pccard_ether_stop"
+restart_precmd=3D"checkauto"
+restart_cmd=3D"pccard_ether_restart"
=20
 setup_routes()
 {
@@ -54,23 +57,17 @@ remove_routes()
 	fi
 }
=20
-ifn=3D$1
-shift
-startstop=3D$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
+}
=20
-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
-	;;
+}
=20
-# 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=3D$1
+shift
+if [ -z "$*" ]; then
+	args=3D"start"
+else
+	args=3D$*
+fi
+
+load_rc_config pccard_ether
+run_rc_command $args

--=20
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

--0OAP2g/MAC+5xKAE
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFDPFPPXY6L6fI4GtQRAptSAJ4qW5VTZAx2YQImYx4LXisedqPyJwCeK0PB
C+CmILqtK4gfrtwFfMRK5BE=
=JOjo
-----END PGP SIGNATURE-----

--0OAP2g/MAC+5xKAE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050929205128.GA18164>