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.
This commit is contained in:
Mike Makonnen 2004-07-30 17:19:35 +00:00
parent 9ec7612a2f
commit 83f00c3c07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132892
2 changed files with 32 additions and 17 deletions

View File

@ -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 $*

View File

@ -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
;;