From cc10a9c33b8fe66944273592dddfcaf73c9d0005 Mon Sep 17 00:00:00 2001 From: mtm Date: Fri, 30 Jul 2004 17:19:35 +0000 Subject: Finish cleanup of rc.d/netif. It's now possible to start/stop more than one interface from the command line: # /etc/rc.d/netif start bfe0 xl0 It's also possible to restart an interface(s): # /etc/rc.d/netif restart bfe0 This required some changes to rc.subr(8) so that if the start/stop commands are overidden the rest of the command line (after the start/stop/etc... cmd) is passed through to the subroutines. --- etc/rc.d/netif | 29 +++++++++++++++++++---------- etc/rc.subr | 20 +++++++++++++------- 2 files changed, 32 insertions(+), 17 deletions(-) (limited to 'etc') diff --git a/etc/rc.d/netif b/etc/rc.d/netif index 63d45dd..44a1bfa 100644 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -42,6 +42,10 @@ _cmdifn= 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_start() network_stop() { + # Set the list of interfaces to work on. + # + _cmdifn=$* + echo -n "Stopping network:" # Deconfigure the interface(s) @@ -96,12 +104,17 @@ network_common() # 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 @@ ifn_stop() return $cfg } -if [ -n "$2" ]; then - _cmdifn="$2" -fi - load_rc_config $name -run_rc_command "$1" +run_rc_command $* diff --git a/etc/rc.subr b/etc/rc.subr index ffbf81a..bce5491 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -463,6 +463,12 @@ run_rc_command() 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 @@ run_rc_command() # 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 @@ run_rc_command() 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 @@ run_rc_command() 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 @@ $command $rc_flags $command_args" 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 @@ $command $rc_flags $command_args" 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 ;; -- cgit v1.1