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
[-- Attachment #1 --]
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@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
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFDPFPPXY6L6fI4GtQRAptSAJ4qW5VTZAx2YQImYx4LXisedqPyJwCeK0PB
C+CmILqtK4gfrtwFfMRK5BE=
=JOjo
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050929205128.GA18164>
