net: net.lo, lots of scripts
The program function in depend blocks is now able to search paths by itself. If passed multiple arguments or multiple calls, at least one of the arguments passed must be a program or a shell builtin (eg ip built into busybox). If a qualified path is specified, only that path will be checked, otherwise it will be checked as a builtin, then $PATH will be checked for the named binary (via type). Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
parent
d02d3af02e
commit
4255ba175b
@ -172,7 +172,9 @@ _configure_variables()
|
|||||||
_which()
|
_which()
|
||||||
{
|
{
|
||||||
local i OIFS
|
local i OIFS
|
||||||
|
# Empty
|
||||||
[ -z "$1" ] && return
|
[ -z "$1" ] && return
|
||||||
|
# check paths
|
||||||
OIFS="$IFS"
|
OIFS="$IFS"
|
||||||
IFS=:
|
IFS=:
|
||||||
for i in $PATH ; do
|
for i in $PATH ; do
|
||||||
@ -181,6 +183,22 @@ _which()
|
|||||||
IFS=$OIFS
|
IFS=$OIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Like _which, but also consider shell builtins, and multiple alternatives
|
||||||
|
_program_available()
|
||||||
|
{
|
||||||
|
[ -z "$1" ] && return 0
|
||||||
|
local x=
|
||||||
|
for x; do
|
||||||
|
case "${x}" in
|
||||||
|
/*) [ -x "${x}" ] && break;;
|
||||||
|
*) type "${x}" >/dev/null 2>&1 && break;;
|
||||||
|
esac
|
||||||
|
unset x
|
||||||
|
done
|
||||||
|
[ -n "${x}" ] && echo $x && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
_show_address()
|
_show_address()
|
||||||
{
|
{
|
||||||
einfo "received address $(_get_inet_address "${IFACE}")"
|
einfo "received address $(_get_inet_address "${IFACE}")"
|
||||||
@ -323,11 +341,10 @@ _load_modules()
|
|||||||
|
|
||||||
eval set -- \$module_${i}_program
|
eval set -- \$module_${i}_program
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
x=
|
if ! _program_available "$@" >/dev/null; then
|
||||||
for x; do
|
vewarn "Skipping module $mod due to missing program: $@"
|
||||||
[ -x "${x}" ] && break
|
continue
|
||||||
done
|
fi
|
||||||
[ -x "${x}" ] || continue
|
|
||||||
fi
|
fi
|
||||||
if ${starting}; then
|
if ${starting}; then
|
||||||
eval set -- \$module_${i}_program_start
|
eval set -- \$module_${i}_program_start
|
||||||
@ -335,15 +352,10 @@ _load_modules()
|
|||||||
eval set -- \$module_${i}_program_stop
|
eval set -- \$module_${i}_program_stop
|
||||||
fi
|
fi
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
x=
|
if ! _program_available "$@" >/dev/null; then
|
||||||
for x; do
|
vewarn "Skipping module $mod due to missing program: $@"
|
||||||
case "${x}" in
|
continue
|
||||||
/*) [ -x "${x}" ] && break;;
|
fi
|
||||||
*) type "${x}" >/dev/null 2>&1 && break;;
|
|
||||||
esac
|
|
||||||
unset x
|
|
||||||
done
|
|
||||||
[ -n "${x}" ] || continue
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval provides=\$module_${i}_provide
|
eval provides=\$module_${i}_provide
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
_br2684ctl()
|
|
||||||
{
|
|
||||||
if [ -x /usr/sbin/br2684ctl ]; then
|
|
||||||
echo /usr/sbin/br2684ctl
|
|
||||||
else
|
|
||||||
echo /sbin/br2684ctl
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
br2684ctl_depend()
|
br2684ctl_depend()
|
||||||
{
|
{
|
||||||
before ppp
|
before ppp
|
||||||
program start $(_br2684ctl)
|
program start br2684ctl
|
||||||
}
|
}
|
||||||
|
|
||||||
_config_vars="$_config_vars bridge bridge_add brctl"
|
_config_vars="$_config_vars bridge bridge_add brctl"
|
||||||
@ -42,7 +33,7 @@ br2684ctl_pre_start()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
einfo "Starting RFC 2684 Bridge control on ${IFACE}"
|
einfo "Starting RFC 2684 Bridge control on ${IFACE}"
|
||||||
start-stop-daemon --start --exec $(_br2684ctl) --background \
|
start-stop-daemon --start --exec $(_which br2684ctl) --background \
|
||||||
--make-pidfile --pidfile "/var/run/br2684ctl-${IFACE}.pid" \
|
--make-pidfile --pidfile "/var/run/br2684ctl-${IFACE}.pid" \
|
||||||
-- -c "${IFACE#nas*}" ${opts}
|
-- -c "${IFACE#nas*}" ${opts}
|
||||||
eend $?
|
eend $?
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
bridge_depend()
|
bridge_depend()
|
||||||
{
|
{
|
||||||
before interface macnet
|
before interface macnet
|
||||||
program /sbin/brctl
|
program brctl
|
||||||
}
|
}
|
||||||
|
|
||||||
_config_vars="$_config_vars bridge bridge_add brctl"
|
_config_vars="$_config_vars bridge bridge_add brctl"
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
ethtool_depend()
|
ethtool_depend()
|
||||||
{
|
{
|
||||||
local x
|
program ethtool
|
||||||
x=$(_which ethtool)
|
|
||||||
[ -z "$x" ] && return 1
|
|
||||||
program $x
|
|
||||||
before interface
|
before interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ _config_vars="$_config_vars link suffix relay"
|
|||||||
ip6to4_depend()
|
ip6to4_depend()
|
||||||
{
|
{
|
||||||
after interface
|
after interface
|
||||||
|
program ip
|
||||||
}
|
}
|
||||||
|
|
||||||
ip6to4_pre_start()
|
ip6to4_pre_start()
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
iproute2_depend()
|
iproute2_depend()
|
||||||
{
|
{
|
||||||
local x
|
program ip
|
||||||
x=$(_which ip)
|
|
||||||
[ -z "$x" ] && return 1
|
|
||||||
program $x
|
|
||||||
provide interface
|
provide interface
|
||||||
after ifconfig
|
after ifconfig
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
macchanger_depend()
|
macchanger_depend()
|
||||||
{
|
{
|
||||||
before macnet
|
before macnet
|
||||||
|
# no program 'macchanger', as we have partial functionality without it
|
||||||
}
|
}
|
||||||
|
|
||||||
_config_vars="$_config_vars mac"
|
_config_vars="$_config_vars mac"
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
|
|
||||||
macvlan_depend()
|
macvlan_depend()
|
||||||
{
|
{
|
||||||
local x
|
program ip
|
||||||
x=$(_which ip)
|
|
||||||
[ -z "${X}" ] && return 1
|
|
||||||
program $x
|
|
||||||
after interface
|
after interface
|
||||||
before dhcp macchanger
|
before dhcp macchanger
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
tuntap_depend()
|
tuntap_depend()
|
||||||
{
|
{
|
||||||
before bridge interface macchanger
|
before bridge interface macchanger
|
||||||
|
program ip openvpn tunctl
|
||||||
}
|
}
|
||||||
|
|
||||||
_config_vars="$_config_vars iproute2 openvpn tunctl"
|
_config_vars="$_config_vars iproute2 openvpn tunctl"
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
vlan_depend()
|
vlan_depend()
|
||||||
{
|
{
|
||||||
local x
|
program ip
|
||||||
x=$(_which ip)
|
|
||||||
[ -z "$x" ] && return 1
|
|
||||||
program $x
|
|
||||||
after interface
|
after interface
|
||||||
before dhcp
|
before dhcp
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user