summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2012-01-08 16:24:03 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2012-01-08 16:24:10 -0800
commit4255ba175bd7c3ccadc5bc894d00ccb844467067 (patch)
tree40965581526479833b09054c5d9dc028348536b9 /init.d
parentd02d3af02e4254b04949de546c5d53af82cc2fc2 (diff)
downloadopenrc-4255ba175bd7c3ccadc5bc894d00ccb844467067.tar.gz
openrc-4255ba175bd7c3ccadc5bc894d00ccb844467067.tar.bz2
openrc-4255ba175bd7c3ccadc5bc894d00ccb844467067.tar.xz
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>
Diffstat (limited to 'init.d')
-rw-r--r--init.d/net.lo.in40
1 files changed, 26 insertions, 14 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index de393bd..2913561 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -172,7 +172,9 @@ _configure_variables()
_which()
{
local i OIFS
+ # Empty
[ -z "$1" ] && return
+ # check paths
OIFS="$IFS"
IFS=:
for i in $PATH ; do
@@ -181,6 +183,22 @@ _which()
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()
{
einfo "received address $(_get_inet_address "${IFACE}")"
@@ -323,11 +341,10 @@ _load_modules()
eval set -- \$module_${i}_program
if [ -n "$1" ]; then
- x=
- for x; do
- [ -x "${x}" ] && break
- done
- [ -x "${x}" ] || continue
+ if ! _program_available "$@" >/dev/null; then
+ vewarn "Skipping module $mod due to missing program: $@"
+ continue
+ fi
fi
if ${starting}; then
eval set -- \$module_${i}_program_start
@@ -335,15 +352,10 @@ _load_modules()
eval set -- \$module_${i}_program_stop
fi
if [ -n "$1" ]; then
- x=
- for x; do
- case "${x}" in
- /*) [ -x "${x}" ] && break;;
- *) type "${x}" >/dev/null 2>&1 && break;;
- esac
- unset x
- done
- [ -n "${x}" ] || continue
+ if ! _program_available "$@" >/dev/null; then
+ vewarn "Skipping module $mod due to missing program: $@"
+ continue
+ fi
fi
eval provides=\$module_${i}_provide