diff options
Diffstat (limited to 'init.d/net.lo.in')
-rw-r--r-- | init.d/net.lo.in | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in index de393bd1..29135614 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 |