2008-03-03 02:44:01 +05:30
|
|
|
#!@PREFIX@/sbin/runscript
|
2009-06-05 13:45:55 +05:30
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2009-05-24 01:08:12 +05:30
|
|
|
MODULESDIR="${RC_LIBEXECDIR}/net"
|
2007-04-05 16:48:42 +05:30
|
|
|
MODULESLIST="${RC_SVCDIR}/nettree"
|
2007-04-10 00:26:26 +05:30
|
|
|
_config_vars="config routes"
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-22 18:58:14 +05:30
|
|
|
[ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO"
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-07-11 00:39:41 +05:30
|
|
|
description="Configures network interfaces."
|
|
|
|
|
2007-10-30 17:07:49 +05:30
|
|
|
# Handy var so we don't have to embed new lines everywhere for array splitting
|
2007-11-28 15:34:15 +05:30
|
|
|
__IFS="
|
2007-10-30 17:07:49 +05:30
|
|
|
"
|
2008-01-11 17:43:46 +05:30
|
|
|
depend()
|
|
|
|
{
|
2008-03-20 01:27:24 +05:30
|
|
|
local IFACE=${RC_SVCNAME#*.}
|
2008-01-02 21:08:37 +05:30
|
|
|
local IFVAR=$(shell_var "${IFACE}")
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2011-04-16 05:51:20 +05:30
|
|
|
need localmount
|
|
|
|
after bootmisc
|
2007-05-02 16:34:52 +05:30
|
|
|
provide net
|
2009-07-01 04:37:32 +05:30
|
|
|
keyword -jail -prefix -vserver
|
2008-01-30 18:50:47 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
case "${IFACE}" in
|
2011-04-16 05:51:20 +05:30
|
|
|
lo|lo0);;
|
|
|
|
*) after net.lo net.lo0;;
|
2007-05-02 16:34:52 +05:30
|
|
|
esac
|
2008-01-30 18:50:47 +05:30
|
|
|
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "depend_${IFVAR}")" = "depend_${IFVAR}" ]; then
|
2008-01-30 18:50:47 +05:30
|
|
|
depend_${IFVAR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
local dep= prov=
|
2008-02-19 20:06:22 +05:30
|
|
|
for dep in need use before after provide keyword; do
|
2008-01-30 18:50:47 +05:30
|
|
|
eval prov=\$rc_${dep}_${IFVAR}
|
|
|
|
if [ -n "${prov}" ]; then
|
|
|
|
${dep} ${prov}
|
|
|
|
fi
|
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2007-10-29 15:15:49 +05:30
|
|
|
# Support bash arrays - sigh
|
2008-01-11 17:43:46 +05:30
|
|
|
_get_array()
|
|
|
|
{
|
2007-10-29 15:15:49 +05:30
|
|
|
local _a=
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${BASH}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
case "$(declare -p "$1" 2>/dev/null)" in
|
2007-05-02 16:34:52 +05:30
|
|
|
"declare -a "*)
|
2007-10-29 15:15:49 +05:30
|
|
|
eval "set -- \"\${$1[@]}\""
|
2007-11-29 16:53:06 +05:30
|
|
|
for _a; do
|
2007-10-29 15:15:49 +05:30
|
|
|
printf "%s\n" "${_a}"
|
|
|
|
done
|
|
|
|
return 0
|
2007-05-02 16:34:52 +05:30
|
|
|
;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-10-29 15:15:49 +05:30
|
|
|
eval _a=\$$1
|
|
|
|
printf "%s" "${_a}"
|
2007-10-30 17:07:49 +05:30
|
|
|
printf "\n"
|
2007-10-29 15:15:49 +05:30
|
|
|
[ -n "${_a}" ]
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2007-11-14 23:53:59 +05:30
|
|
|
# Flatten bash arrays to simple strings
|
2008-01-11 17:43:46 +05:30
|
|
|
_flatten_array()
|
|
|
|
{
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${BASH}" ]; then
|
2007-11-14 23:53:59 +05:30
|
|
|
case "$(declare -p "$1" 2>/dev/null)" in
|
|
|
|
"declare -a "*)
|
|
|
|
eval "set -- \"\${$1[@]}\""
|
2007-11-29 16:53:06 +05:30
|
|
|
for x; do
|
2007-11-14 23:53:59 +05:30
|
|
|
printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval _a=\$$1
|
|
|
|
printf "%s" "${_a}"
|
|
|
|
printf "\n"
|
|
|
|
[ -n "${_a}" ]
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_wait_for_carrier()
|
|
|
|
{
|
2007-05-02 16:34:52 +05:30
|
|
|
local timeout= efunc=einfon
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
_has_carrier && return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
eval timeout=\$carrier_timeout_${IFVAR}
|
|
|
|
timeout=${timeout:-${carrier_timeout:-5}}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-04-30 18:47:28 +05:30
|
|
|
# Incase users don't want this nice feature ...
|
|
|
|
[ ${timeout} -le 0 ] && return 0
|
|
|
|
|
2007-11-22 19:07:24 +05:30
|
|
|
yesno ${RC_PARALLEL} && efunc=einfo
|
2007-05-02 16:34:52 +05:30
|
|
|
${efunc} "Waiting for carrier (${timeout} seconds) "
|
2007-11-28 21:15:03 +05:30
|
|
|
while [ ${timeout} -gt 0 ]; do
|
2007-04-05 16:48:42 +05:30
|
|
|
sleep 1
|
2007-11-28 21:15:03 +05:30
|
|
|
if _has_carrier; then
|
2007-07-11 17:36:37 +05:30
|
|
|
[ "${efunc}" = "einfon" ] && echo
|
2007-04-11 16:10:53 +05:30
|
|
|
eend 0
|
2007-05-02 16:34:52 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
timeout=$((${timeout} - 1))
|
2007-07-11 17:36:37 +05:30
|
|
|
[ "${efunc}" = "einfon" ] && printf "."
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-07-11 17:36:37 +05:30
|
|
|
[ "${efunc}" = "einfon" ] && echo
|
2007-04-11 16:10:53 +05:30
|
|
|
eend 1
|
2007-05-02 16:34:52 +05:30
|
|
|
return 1
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_netmask2cidr()
|
|
|
|
{
|
2008-01-10 23:41:02 +05:30
|
|
|
# Some shells cannot handle hex arithmetic, so we massage it slightly
|
|
|
|
# Buggy shells include FreeBSD sh, dash and busybox.
|
|
|
|
# bash and NetBSD sh don't need this.
|
|
|
|
case $1 in
|
|
|
|
0x*)
|
|
|
|
local hex=${1#0x*} quad=
|
|
|
|
while [ -n "${hex}" ]; do
|
|
|
|
local lastbut2=${hex#??*}
|
|
|
|
quad=${quad}${quad:+.}0x${hex%${lastbut2}*}
|
|
|
|
hex=${lastbut2}
|
|
|
|
done
|
|
|
|
set -- ${quad}
|
|
|
|
;;
|
|
|
|
esac
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-01-10 23:41:02 +05:30
|
|
|
local i= len=
|
2007-05-02 16:34:52 +05:30
|
|
|
local IFS=.
|
|
|
|
for i in $1; do
|
2007-11-28 21:15:03 +05:30
|
|
|
while [ ${i} != "0" ]; do
|
2007-05-02 16:34:52 +05:30
|
|
|
len=$((${len} + ${i} % 2))
|
|
|
|
i=$((${i} >> 1))
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
echo "${len}"
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_configure_variables()
|
|
|
|
{
|
2007-05-02 16:34:52 +05:30
|
|
|
local var= v= t=
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for var in ${_config_vars}; do
|
2007-04-05 16:48:42 +05:30
|
|
|
local v=
|
2007-11-29 16:53:06 +05:30
|
|
|
for t; do
|
2007-05-02 16:34:52 +05:30
|
|
|
eval v=\$${var}_${t}
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${v}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
eval ${var}_${IFVAR}=\$${var}_${t}
|
|
|
|
continue 2
|
|
|
|
fi
|
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_show_address()
|
|
|
|
{
|
2007-05-02 16:34:52 +05:30
|
|
|
einfo "received address $(_get_inet_address "${IFACE}")"
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
# Basically sorts our modules into order and saves the list
|
2008-01-11 17:43:46 +05:30
|
|
|
_gen_module_list()
|
|
|
|
{
|
2007-05-19 01:39:10 +05:30
|
|
|
local x= f= force=$1
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
local update=false
|
2008-01-29 21:11:10 +05:30
|
|
|
for x in "${MODULESDIR}"/*.sh; do
|
2007-05-02 16:34:52 +05:30
|
|
|
[ -e "${x}" ] || continue
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ "${x}" -nt "${MODULESLIST}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
update=true
|
|
|
|
break
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
${update} || return 0
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2011-01-17 15:19:07 +05:30
|
|
|
einfo "Caching network module dependencies"
|
2007-05-02 16:34:52 +05:30
|
|
|
# Run in a subshell to protect the main script
|
|
|
|
(
|
|
|
|
after() {
|
2007-04-05 16:48:42 +05:30
|
|
|
eval ${MODULE}_after="\"\${${MODULE}_after}\${${MODULE}_after:+ }$*\""
|
2007-05-02 16:34:52 +05:30
|
|
|
}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
before() {
|
2007-04-05 16:48:42 +05:30
|
|
|
local mod=${MODULE}
|
|
|
|
local MODULE=
|
2007-11-29 16:53:06 +05:30
|
|
|
for MODULE; do
|
2007-05-02 16:34:52 +05:30
|
|
|
after "${mod}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
program() {
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ "$1" = "start" -o "$1" = "stop" ]; then
|
2007-05-02 16:34:52 +05:30
|
|
|
local s="$1"
|
|
|
|
shift
|
|
|
|
eval ${MODULE}_program_${s}="\"\${${MODULE}_program_${s}}\${${MODULE}_program_${s}:+ }$*\""
|
2007-04-05 16:48:42 +05:30
|
|
|
else
|
2007-05-02 16:34:52 +05:30
|
|
|
eval ${MODULE}_program="\"\${${MODULE}_program}\${${MODULE}_program:+ }$*\""
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
provide() {
|
2007-04-05 16:48:42 +05:30
|
|
|
eval ${MODULE}_provide="\"\${${MODULE}_provide}\${${MODULE}_provide:+ }$*\""
|
|
|
|
local x
|
2007-11-28 21:15:03 +05:30
|
|
|
for x in $*; do
|
2007-05-02 16:34:52 +05:30
|
|
|
eval ${x}_providedby="\"\${${MODULE}_providedby}\${${MODULE}_providedby:+ }${MODULE}\""
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-01-29 21:11:10 +05:30
|
|
|
for MODULE in "${MODULESDIR}"/*.sh; do
|
2007-04-05 16:48:42 +05:30
|
|
|
sh -n "${MODULE}" || continue
|
2011-01-17 15:19:07 +05:30
|
|
|
. "${MODULE}" || continue
|
2007-04-05 16:48:42 +05:30
|
|
|
MODULE=${MODULE#${MODULESDIR}/}
|
|
|
|
MODULE=${MODULE%.sh}
|
|
|
|
eval ${MODULE}_depend
|
|
|
|
MODULES="${MODULES} ${MODULE}"
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
VISITED=
|
|
|
|
SORTED=
|
|
|
|
visit() {
|
2007-04-05 16:48:42 +05:30
|
|
|
case " ${VISITED} " in
|
2007-11-28 21:15:03 +05:30
|
|
|
*" $1 "*) return;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
|
|
|
VISITED="${VISITED} $1"
|
|
|
|
|
|
|
|
eval AFTER=\$${1}_after
|
2007-11-28 21:15:03 +05:30
|
|
|
for MODULE in ${AFTER}; do
|
2007-05-02 16:34:52 +05:30
|
|
|
eval PROVIDEDBY=\$${MODULE}_providedby
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${PROVIDEDBY}" ]; then
|
|
|
|
for MODULE in ${PROVIDEDBY}; do
|
2007-05-02 16:34:52 +05:30
|
|
|
visit "${MODULE}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
else
|
2007-04-05 16:48:42 +05:30
|
|
|
visit "${MODULE}"
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
|
|
|
|
eval PROVIDE=\$${1}_provide
|
2007-11-28 21:15:03 +05:30
|
|
|
for MODULE in ${PROVIDE}; do
|
2007-05-02 16:34:52 +05:30
|
|
|
visit "${MODULE}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
|
|
|
|
eval PROVIDEDBY=\$${1}_providedby
|
|
|
|
[ -z "${PROVIDEDBY}" ] && SORTED="${SORTED} $1"
|
2007-05-02 16:34:52 +05:30
|
|
|
}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for MODULE in ${MODULES}; do
|
2007-04-05 16:48:42 +05:30
|
|
|
visit "${MODULE}"
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-18 02:29:55 +05:30
|
|
|
printf "" > "${MODULESLIST}"
|
2007-05-02 16:34:52 +05:30
|
|
|
i=0
|
2007-11-28 21:15:03 +05:30
|
|
|
for MODULE in ${SORTED}; do
|
2007-04-05 16:48:42 +05:30
|
|
|
eval PROGRAM=\$${MODULE}_program
|
|
|
|
eval PROGRAM_START=\$${MODULE}_program_start
|
|
|
|
eval PROGRAM_STOP=\$${MODULE}_program_stop
|
|
|
|
eval PROVIDE=\$${MODULE}_provide
|
|
|
|
echo "module_${i}='${MODULE}'" >> "${MODULESLIST}"
|
|
|
|
echo "module_${i}_program='${PROGRAM}'" >> "${MODULESLIST}"
|
|
|
|
echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}"
|
|
|
|
echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}"
|
|
|
|
echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}"
|
|
|
|
i=$((${i} + 1))
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
|
|
|
echo "module_${i}=" >> "${MODULESLIST}"
|
|
|
|
)
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_load_modules()
|
|
|
|
{
|
2007-05-02 16:34:52 +05:30
|
|
|
local starting=$1 mymods=
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-19 01:39:10 +05:30
|
|
|
# Ensure our list is up to date
|
|
|
|
_gen_module_list false
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! . "${MODULESLIST}"; then
|
2007-05-19 01:39:10 +05:30
|
|
|
_gen_module_list true
|
|
|
|
. "${MODULESLIST}"
|
|
|
|
fi
|
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
MODULES=
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
eval mymods=\$modules_${IFVAR}
|
|
|
|
[ -z "${mymods}" ] && mymods=${modules}
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
local i=-1 x= mod= f= provides=
|
2007-11-28 21:15:03 +05:30
|
|
|
while true; do
|
2007-04-05 16:48:42 +05:30
|
|
|
i=$((${i} + 1))
|
|
|
|
eval mod=\$module_${i}
|
|
|
|
[ -z "${mod}" ] && break
|
|
|
|
[ -e "${MODULESDIR}/${mod}.sh" ] || continue
|
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
eval set -- \$module_${i}_program
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "$1" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
x=
|
2007-11-29 16:53:06 +05:30
|
|
|
for x; do
|
2007-04-05 16:48:42 +05:30
|
|
|
[ -x "${x}" ] && break
|
|
|
|
done
|
|
|
|
[ -x "${x}" ] || continue
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-11-28 21:15:03 +05:30
|
|
|
if ${starting}; then
|
2007-04-05 16:48:42 +05:30
|
|
|
eval set -- \$module_${i}_program_start
|
|
|
|
else
|
|
|
|
eval set -- \$module_${i}_program_stop
|
|
|
|
fi
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "$1" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
x=
|
2007-11-29 16:53:06 +05:30
|
|
|
for x; do
|
2008-01-11 04:53:39 +05:30
|
|
|
case "${x}" in
|
|
|
|
/*) [ -x "${x}" ] && break;;
|
|
|
|
*) type "${x}" >/dev/null 2>&1 && break;;
|
|
|
|
esac
|
|
|
|
unset x
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2008-01-11 04:53:39 +05:30
|
|
|
[ -n "${x}" ] || continue
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
eval provides=\$module_${i}_provide
|
2007-11-28 21:15:03 +05:30
|
|
|
if ${starting}; then
|
2007-05-02 16:34:52 +05:30
|
|
|
case " ${mymods} " in
|
2007-11-28 21:15:03 +05:30
|
|
|
*" !${mod} "*) continue;;
|
|
|
|
*" !${provides} "*) [ -n "${provides}" ] && continue;;
|
2007-05-02 16:34:52 +05:30
|
|
|
esac
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
MODULES="${MODULES}${MODULES:+ }${mod}"
|
|
|
|
|
|
|
|
# Now load and wrap our functions
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! . "${MODULESDIR}/${mod}.sh"; then
|
2008-03-20 01:27:24 +05:30
|
|
|
eend 1 "${RC_SVCNAME}: error loading module \`${mod}'"
|
2007-05-02 16:34:52 +05:30
|
|
|
exit 1
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
[ -z "${provides}" ] && continue
|
|
|
|
|
|
|
|
# Wrap our provides
|
|
|
|
local f=
|
2011-01-17 15:19:07 +05:30
|
|
|
for f in pre_start start post_start; do
|
2008-04-21 23:02:17 +05:30
|
|
|
eval "${provides}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
|
|
|
|
eval module_${mod}_provides="${provides}"
|
|
|
|
eval module_${provides}_providedby="${mod}"
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
# Wrap our preferred modules
|
2007-11-28 21:15:03 +05:30
|
|
|
for mod in ${mymods}; do
|
2007-04-05 16:48:42 +05:30
|
|
|
case " ${MODULES} " in
|
2007-05-02 16:34:52 +05:30
|
|
|
*" ${mod} "*)
|
|
|
|
eval x=\$module_${mod}_provides
|
|
|
|
[ -z "${x}" ] && continue
|
2011-01-17 15:19:07 +05:30
|
|
|
for f in pre_start start post_start; do
|
2008-04-21 23:02:17 +05:30
|
|
|
eval "${x}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
|
|
|
eval module_${x}_providedby="${mod}"
|
|
|
|
;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
# Finally remove any duplicated provides from our list if we're starting
|
|
|
|
# Otherwise reverse the list
|
|
|
|
local LIST="${MODULES}" p=
|
|
|
|
MODULES=
|
2007-11-28 21:15:03 +05:30
|
|
|
if ${starting}; then
|
|
|
|
for mod in ${LIST}; do
|
2007-05-02 16:34:52 +05:30
|
|
|
eval x=\$module_${mod}_provides
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${x}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
eval p=\$module_${x}_providedby
|
|
|
|
[ "${mod}" != "${p}" ] && continue
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
|
|
|
MODULES="${MODULES}${MODULES:+ }${mod}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
else
|
2011-01-17 15:19:07 +05:30
|
|
|
for mod in ${LIST}; do
|
2007-05-02 16:34:52 +05:30
|
|
|
MODULES="${mod}${MODULES:+ }${MODULES}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
veinfo "Loaded modules: ${MODULES}"
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
_load_config()
|
|
|
|
{
|
2007-10-29 15:15:49 +05:30
|
|
|
local config="$(_get_array "config_${IFVAR}")"
|
|
|
|
local fallback="$(_get_array fallback_${IFVAR})"
|
|
|
|
|
2007-11-29 16:47:50 +05:30
|
|
|
config_index=0
|
|
|
|
local IFS="$__IFS"
|
|
|
|
set -- ${config}
|
2011-01-17 15:19:07 +05:30
|
|
|
|
2007-11-29 16:47:50 +05:30
|
|
|
# We should support a space separated array for cidr configs
|
|
|
|
if [ $# = 1 ]; then
|
|
|
|
unset IFS
|
|
|
|
set -- ${config}
|
|
|
|
# Of course, we may have a single address added old style.
|
|
|
|
case "$2" in
|
2010-12-12 07:59:34 +05:30
|
|
|
netmask|broadcast|brd|brd+|peer|pointopoint)
|
2007-11-29 16:47:50 +05:30
|
|
|
local IFS="$__IFS"
|
|
|
|
set -- ${config}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2007-11-30 15:08:01 +05:30
|
|
|
# Ensure that loopback has the correct address
|
|
|
|
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
|
|
|
|
if [ "$1" != "null" ]; then
|
|
|
|
config_0="127.0.0.1/8"
|
|
|
|
config_index=1
|
|
|
|
fi
|
2011-01-17 15:19:07 +05:30
|
|
|
else
|
2007-11-30 15:08:01 +05:30
|
|
|
if [ -z "$1" ]; then
|
|
|
|
ewarn "No configuration specified; defaulting to DHCP"
|
2007-11-30 15:29:10 +05:30
|
|
|
config_0="dhcp"
|
|
|
|
config_index=1
|
2007-11-30 15:08:01 +05:30
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
# We store our config in an array like vars
|
|
|
|
# so modules can influence it
|
2007-11-29 16:47:50 +05:30
|
|
|
for cmd; do
|
2007-04-05 16:48:42 +05:30
|
|
|
eval config_${config_index}="'${cmd}'"
|
|
|
|
config_index=$((${config_index} + 1))
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
|
|
|
# Terminate the list
|
|
|
|
eval config_${config_index}=
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
config_index=0
|
2007-10-29 15:15:49 +05:30
|
|
|
for cmd in ${fallback}; do
|
2007-11-01 23:45:30 +05:30
|
|
|
eval fallback_${config_index}="'${cmd}'"
|
2007-04-05 16:48:42 +05:30
|
|
|
config_index=$((${config_index} + 1))
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
|
|
|
# Terminate the list
|
|
|
|
eval fallback_${config_index}=
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# Don't set to zero, so any net modules don't have to do anything extra
|
2007-05-02 16:34:52 +05:30
|
|
|
config_index=-1
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-11-10 18:01:20 +05:30
|
|
|
# Support functions
|
|
|
|
_run_if()
|
|
|
|
{
|
|
|
|
local cmd=$1 iface=$2 ifr=${IFACE} ifv=${IFVAR}
|
|
|
|
# Ensure that we don't stamp on real values
|
|
|
|
local IFACE= IFVAR=
|
|
|
|
shift
|
|
|
|
if [ -n "${iface}" ]; then
|
|
|
|
IFACE="${iface}"
|
|
|
|
[ "${iface}" != "${ifr}" ] && IFVAR=$(shell_var "${IFACE}")
|
|
|
|
else
|
|
|
|
IFACE=${ifr}
|
|
|
|
IFVAR=${ifv}
|
|
|
|
fi
|
|
|
|
${cmd}
|
|
|
|
}
|
|
|
|
interface_exists()
|
|
|
|
{
|
|
|
|
_run_if _exists "$@"
|
|
|
|
}
|
|
|
|
interface_up()
|
|
|
|
{
|
|
|
|
_run_if _up "$@"
|
|
|
|
}
|
|
|
|
interface_down()
|
|
|
|
{
|
|
|
|
_run_if _down "$@"
|
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
2011-04-10 00:24:01 +05:30
|
|
|
local IFACE=${RC_SVCNAME#*.} oneworked=false fallback=false module=
|
2008-01-02 21:08:37 +05:30
|
|
|
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
|
2007-12-31 14:58:34 +05:30
|
|
|
local metric=0
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
einfo "Bringing up interface ${IFACE}"
|
|
|
|
eindent
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -z "${MODULES}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
local MODULES=
|
|
|
|
_load_modules true
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-07-04 19:51:24 +05:30
|
|
|
# We up the iface twice if we have a preup to ensure it's up if
|
|
|
|
# available in preup and afterwards incase the user inadvertently
|
|
|
|
# brings it down
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v preup)" = "preup" ]; then
|
2007-07-04 19:51:24 +05:30
|
|
|
_up 2>/dev/null
|
2007-04-05 16:48:42 +05:30
|
|
|
ebegin "Running preup"
|
|
|
|
eindent
|
|
|
|
preup || return 1
|
|
|
|
eoutdent
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-07-04 19:51:24 +05:30
|
|
|
_up 2>/dev/null
|
2011-01-17 15:19:07 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for module in ${MODULES}; do
|
2008-04-22 00:56:56 +05:30
|
|
|
if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then
|
2008-01-11 23:11:19 +05:30
|
|
|
${module}_pre_start || exit $?
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! _exists; then
|
2007-04-19 12:16:29 +05:30
|
|
|
eerror "ERROR: interface ${IFACE} does not exist"
|
|
|
|
eerror "Ensure that you have loaded the correct kernel module for your hardware"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! _wait_for_carrier; then
|
|
|
|
if service_started devd; then
|
2007-04-11 16:10:53 +05:30
|
|
|
ewarn "no carrier, but devd will start us when we have one"
|
2008-03-20 01:27:24 +05:30
|
|
|
mark_service_inactive "${RC_SVCNAME}"
|
2007-04-11 16:10:53 +05:30
|
|
|
else
|
|
|
|
eerror "no carrier"
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
local config= config_index=
|
|
|
|
_load_config
|
2007-04-05 16:48:42 +05:30
|
|
|
config_index=0
|
|
|
|
|
2011-01-17 15:19:07 +05:30
|
|
|
eval our_metric=\$metric_${IFVAR}
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${our_metric}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
metric=${our_metric}
|
2007-11-28 21:15:03 +05:30
|
|
|
elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
metric=$((${metric} + $(_ifindex)))
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
while true; do
|
2007-04-05 16:48:42 +05:30
|
|
|
eval config=\$config_${config_index}
|
2011-01-17 15:19:07 +05:30
|
|
|
[ -z "${config}" ] && break
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-29 15:15:57 +05:30
|
|
|
set -- ${config}
|
|
|
|
ebegin "$1"
|
2007-04-05 16:48:42 +05:30
|
|
|
eindent
|
|
|
|
case "$1" in
|
2007-05-02 16:34:52 +05:30
|
|
|
noop)
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "$(_get_inet_address)" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
oneworked=true
|
|
|
|
break
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
|
|
|
;;
|
2007-11-28 21:15:03 +05:30
|
|
|
null) :;;
|
|
|
|
[0-9]*|*:*) _add_address ${config};;
|
2007-05-02 16:34:52 +05:30
|
|
|
*)
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "${config}_start")" = "${config}_start" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
"${config}"_start
|
2007-05-02 16:34:52 +05:30
|
|
|
else
|
2007-04-05 16:48:42 +05:30
|
|
|
eerror "nothing provides \`${config}'"
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
|
|
|
;;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
2007-11-28 21:15:03 +05:30
|
|
|
if eend $?; then
|
2007-05-02 16:34:52 +05:30
|
|
|
oneworked=true
|
2007-04-05 16:48:42 +05:30
|
|
|
else
|
2007-09-18 03:08:58 +05:30
|
|
|
eval config=\$fallback_${config_index}
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -n "${config}" ]; then
|
2011-04-10 00:24:01 +05:30
|
|
|
fallback=true
|
2007-09-18 03:08:58 +05:30
|
|
|
eoutdent
|
|
|
|
ewarn "Trying fallback configuration ${config}"
|
|
|
|
eindent
|
|
|
|
eval config_${config_index}=\$config
|
|
|
|
unset fallback_${config_index}
|
2007-04-05 16:48:42 +05:30
|
|
|
config_index=$((${config_index} - 1))
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
eoutdent
|
|
|
|
config_index=$((${config_index} + 1))
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if ! ${oneworked}; then
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v failup)" = "failup" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
ebegin "Running failup"
|
|
|
|
eindent
|
|
|
|
failup
|
|
|
|
eoutdent
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2011-04-10 00:24:01 +05:30
|
|
|
local hidefirstroute=false first=true routes=
|
|
|
|
if ${fallback}; then
|
|
|
|
routes="$(_get_array "fallback_routes_${IFVAR}")"
|
|
|
|
fi
|
|
|
|
if [ -z "${routes}" ]; then
|
|
|
|
routes="$(_get_array "routes_${IFVAR}")"
|
|
|
|
fi
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
|
2007-11-02 03:55:53 +05:30
|
|
|
if [ "${config_0}" != "null" ]; then
|
|
|
|
routes="127.0.0.0/8 via 127.0.0.1
|
2007-10-29 15:15:49 +05:30
|
|
|
${routes}"
|
2007-11-02 03:55:53 +05:30
|
|
|
hidefirstroute=true
|
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-12-04 19:48:41 +05:30
|
|
|
|
2008-12-30 05:35:17 +05:30
|
|
|
local OIFS="${IFS}" SIFS="${IFS-y}"
|
2007-10-30 17:07:49 +05:30
|
|
|
local IFS="$__IFS"
|
2007-10-29 15:15:49 +05:30
|
|
|
for cmd in ${routes}; do
|
|
|
|
unset IFS
|
|
|
|
if ${first}; then
|
2007-05-02 16:34:52 +05:30
|
|
|
first=false
|
|
|
|
einfo "Adding routes"
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
eindent
|
2007-11-02 22:33:29 +05:30
|
|
|
ebegin ${cmd}
|
2007-04-05 16:48:42 +05:30
|
|
|
# Work out if we're a host or a net if not told
|
2007-11-28 15:34:15 +05:30
|
|
|
case ${cmd} in
|
2007-11-29 15:15:57 +05:30
|
|
|
-net" "*|-host" "*);;
|
2007-12-31 14:58:53 +05:30
|
|
|
*" "netmask" "*) cmd="-net ${cmd}";;
|
2008-01-15 17:43:42 +05:30
|
|
|
*.*.*.*/32*) cmd="-host ${cmd}";;
|
2008-10-14 20:57:52 +05:30
|
|
|
*.*.*.*/*|0.0.0.0|0.0.0.0" "*) cmd="-net ${cmd}";;
|
|
|
|
default|default" "*) cmd="-net ${cmd}";;
|
2007-12-31 14:58:53 +05:30
|
|
|
*) cmd="-host ${cmd}";;
|
2007-04-05 16:48:42 +05:30
|
|
|
esac
|
2007-11-28 21:15:03 +05:30
|
|
|
if ${hidefirstroute}; then
|
|
|
|
_add_route ${cmd} >/dev/null 2>&1
|
2007-05-02 16:34:52 +05:30
|
|
|
hidefirstroute=false
|
2007-04-05 16:48:42 +05:30
|
|
|
else
|
2007-05-02 16:34:52 +05:30
|
|
|
_add_route ${cmd} >/dev/null
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
eend $?
|
|
|
|
eoutdent
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-12-04 19:48:41 +05:30
|
|
|
if [ "${SIFS}" = "y" ]; then
|
|
|
|
unset IFS
|
|
|
|
else
|
|
|
|
IFS="${OIFS}"
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for module in ${MODULES}; do
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "${module}_post_start")" = "${module}_post_start" ]; then
|
2008-01-11 23:11:19 +05:30
|
|
|
${module}_post_start || exit $?
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v postup)" = "postup" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
ebegin "Running postup"
|
|
|
|
eindent
|
2011-01-17 15:19:07 +05:30
|
|
|
postup
|
2007-04-05 16:48:42 +05:30
|
|
|
eoutdent
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
stop()
|
|
|
|
{
|
2008-03-20 01:27:24 +05:30
|
|
|
local IFACE=${RC_SVCNAME#*.} module=
|
2008-01-02 21:08:37 +05:30
|
|
|
local IFVAR=$(shell_var "${IFACE}") opts=
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
einfo "Bringing down interface ${IFACE}"
|
|
|
|
eindent
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if [ -z "${MODULES}" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
local MODULES=
|
|
|
|
_load_modules false
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v predown)" = "predown" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
ebegin "Running predown"
|
|
|
|
eindent
|
|
|
|
predown || return 1
|
|
|
|
eoutdent
|
2007-09-28 18:16:59 +05:30
|
|
|
else
|
|
|
|
if is_net_fs /; then
|
|
|
|
eerror "root filesystem is network mounted -- can't stop ${IFACE}"
|
|
|
|
return 1
|
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for module in ${MODULES}; do
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "${module}_pre_stop")" = "${module}_pre_stop" ]; then
|
2008-01-11 23:11:19 +05:30
|
|
|
${module}_pre_stop || exit $?
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for module in ${MODULES}; do
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "${module}_stop")" = "${module}_stop" ]; then
|
2007-05-02 16:34:52 +05:30
|
|
|
${module}_stop
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2009-05-29 19:53:23 +05:30
|
|
|
# Only delete addresses for interfaces that exist
|
|
|
|
if _exists; then
|
2011-03-22 10:19:40 +05:30
|
|
|
# PPP can manage it's own addresses when IN_BACKGROUND
|
|
|
|
# Important in case "demand" set on the ppp link
|
|
|
|
if ! (yesno ${IN_BACKGROUND} && is_ppp) ; then
|
|
|
|
_delete_addresses "${IFACE}"
|
|
|
|
fi
|
2007-05-02 16:29:34 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
for module in ${MODULES}; do
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "${module}_post_stop")" = "${module}_post_stop" ]; then
|
2007-05-02 16:34:52 +05:30
|
|
|
${module}_post_stop
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-05-02 16:34:52 +05:30
|
|
|
done
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-05-09 15:59:06 +05:30
|
|
|
# If not in background, and not loopback then bring the interface down
|
|
|
|
# unless overridden.
|
|
|
|
if ! yesno ${IN_BACKGROUND} && \
|
|
|
|
[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
|
|
|
|
eval module=\$ifdown_${IFVAR}
|
2008-06-03 17:21:36 +05:30
|
|
|
module=${module:-${ifdown:-YES}}
|
2008-05-09 15:59:06 +05:30
|
|
|
yesno ${module} && _down 2>/dev/null
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-02-12 01:34:15 +05:30
|
|
|
type resolvconf >/dev/null 2>&1 && resolvconf -d "${IFACE}" 2>/dev/null
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2008-04-21 23:02:17 +05:30
|
|
|
if [ "$(command -v "postdown")" = "postdown" ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
ebegin "Running postdown"
|
|
|
|
eindent
|
|
|
|
postdown
|
|
|
|
eoutdent
|
2007-05-02 16:34:52 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-05-02 16:34:52 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|