summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2004-07-30 17:19:35 +0000
committermtm <mtm@FreeBSD.org>2004-07-30 17:19:35 +0000
commitcc10a9c33b8fe66944273592dddfcaf73c9d0005 (patch)
tree5b3df6bc3177db80eac76e942831d4d30a88895b /etc
parent883988043400c9f44deb3cfba74345e361b61515 (diff)
downloadFreeBSD-src-cc10a9c33b8fe66944273592dddfcaf73c9d0005.zip
FreeBSD-src-cc10a9c33b8fe66944273592dddfcaf73c9d0005.tar.gz
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.
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/netif29
-rw-r--r--etc/rc.subr20
2 files changed, 32 insertions, 17 deletions
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
;;
OpenPOWER on IntegriCloud