From owner-freebsd-rc@FreeBSD.ORG Mon Jul 26 09:27:38 2004 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1971116A4CE for ; Mon, 26 Jul 2004 09:27:38 +0000 (GMT) Received: from telecom.net.et (ns2.telecom.net.et [213.55.64.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id 84D3243D49 for ; Mon, 26 Jul 2004 09:27:28 +0000 (GMT) (envelope-from mtm@identd.net) Received: from [213.55.65.151] (HELO pool-151-200-10-97.res.east.verizon.net) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP-TLS id 52635681 for freebsd-rc@freebsd.org; Mon, 26 Jul 2004 12:20:45 +0300 Received: from rogue.acs-et.com (localhost [127.0.0.1]) ESMTP id i6Q9SW4P001409 for ; Mon, 26 Jul 2004 12:28:34 +0300 (EAT) (envelope-from mtm@rogue.acs-et.com) Received: (from mtm@localhost) by rogue.acs-et.com (8.12.11/8.12.11/Submit) id i6Q9SVKr001408 for freebsd-rc@freebsd.org; Mon, 26 Jul 2004 12:28:31 +0300 (EAT) (envelope-from mtm) Date: Mon, 26 Jul 2004 12:28:31 +0300 From: Mike Makonnen To: freebsd-rc@freebsd.org Message-ID: <20040726092831.GC1260@rogue.acs-et.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="E39vaYmALEf/7YXx" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD/5.2-CURRENT (i386) Subject: rc.d/netif cleanups X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to /etc/rc.d design and implementation. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jul 2004 09:27:38 -0000 --E39vaYmALEf/7YXx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline hi folks, Currently, rc.d/netif allows one to start or stop a specific interface. However, you can't specify more than one interface and it doesn't work with the 'restart' command. To fix this I've modified rc.subr to pass additional commands supplied on the command line to the custom start/prestart/poststart/stop/prestop/poststop... I would appreciate comments and additional testing. Thanks. Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon ! --E39vaYmALEf/7YXx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff Index: etc/rc.subr =================================================================== RCS file: /home/ncvs/src/etc/rc.subr,v retrieving revision 1.30 diff -u -r1.30 rc.subr --- etc/rc.subr 4 Jul 2004 07:21:18 -0000 1.30 +++ etc/rc.subr 25 Jul 2004 18:40:52 -0000 @@ -463,6 +463,12 @@ err 3 'run_rc_command: $name is not set.' fi + # Don't repeat the first argument when passing additional command- + # line arguments to the command subroutines. + # + shift 1 + rc_extra_args="$*" + _rc_prefix= case "$rc_arg" in fast*) # "fast" prefix; don't check pid @@ -556,7 +562,7 @@ # if [ -n "$_precmd" ]; then debug "run_rc_command: evaluating ${_precmd}()." - eval $_precmd + eval $_precmd $rc_extra_args _return=$? [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 @@ -564,7 +570,7 @@ if [ -n "$_cmd" ]; then debug "run_rc_command: evaluating ${_cmd}()." - eval $_cmd + eval $_cmd $rc_extra_args _return=$? [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 @@ -572,7 +578,7 @@ if [ -n "$_postcmd" ]; then debug "run_rc_command: evaluating ${_postcmd}()." - eval $_postcmd + eval $_postcmd $rc_extra_args _return=$? fi return $_return @@ -751,7 +757,7 @@ restart) if [ -n "$_precmd" ]; then - eval $_precmd + eval $_precmd $rc_extra_args _return=$? [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1 @@ -764,11 +770,11 @@ fi _rc_restart_done=true - ( $0 ${_rc_prefix}stop ) - $0 ${_rc_prefix}start + ( $0 ${_rc_prefix}stop $rc_extra_args ) + $0 ${_rc_prefix}start $rc_extra_args if [ -n "$_postcmd" ]; then - eval $_postcmd + eval $_postcmd $rc_extra_args _return=$? fi ;; Index: etc/rc.d/netif =================================================================== RCS file: /home/ncvs/src/etc/rc.d/netif,v retrieving revision 1.9 diff -u -r1.9 netif --- etc/rc.d/netif 20 May 2004 15:53:49 -0000 1.9 +++ etc/rc.d/netif 25 Jul 2004 19:11:02 -0000 @@ -42,6 +42,10 @@ network_start() { + # Set the list of interfaces to work on. + # + _cmdifn=$* + if [ -z "$_cmdifn" ]; then # # We're operating as a general network start routine. @@ -65,6 +69,10 @@ network_stop() { + # Set the list of interfaces to work on. + # + _cmdifn=$* + echo -n "Stopping network:" # Deconfigure the interface(s) @@ -96,12 +104,17 @@ # Set the scope of the command (all interfaces or just one). # - _cooked_list="$_ifn_list" + _cooked_list= if [ -n "$_cmdifn" ]; then - eval _cooked_list=\"`expr "$_ifn_list" : ".*\($_cmdifn\).*"`\" - if [ -z "$_cooked_list" ]; then - err 1 "No such network interface: $_cmdifn" - fi + for i in $_cmdifn ; do + eval _if=\"`expr "$_ifn_list" : ".*\(${i}\).*"`\" + if [ -z "$_if" ]; then + err 1 "No such network interface: $i" + fi + _cooked_list="$_cooked_list $_if" + done + else + _cooked_list="$_ifn_list" fi for ifn in ${_cooked_list}; do @@ -159,9 +172,5 @@ return $cfg } -if [ -n "$2" ]; then - _cmdifn="$2" -fi - load_rc_config $name -run_rc_command "$1" +run_rc_command $* --E39vaYmALEf/7YXx--