Fix babeld interface configuration in init script
This commit is contained in:
parent
35b886649b
commit
201f9d5bf2
1 changed files with 24 additions and 19 deletions
|
@ -113,34 +113,39 @@ babel_config_cb() {
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
"interface")
|
"interface")
|
||||||
|
{
|
||||||
|
local _ignored
|
||||||
|
config_get_bool _ignored "$section" 'ignore' 0
|
||||||
|
[ "$_ignored" == "1" ] && return
|
||||||
|
|
||||||
local _ifname
|
local _ifname
|
||||||
config_get _ifname "$section" 'ifname'
|
config_get _ifname "$section" 'ifname'
|
||||||
|
|
||||||
# Try to resolve the logical interface name
|
# Try to resolve the logical interface name
|
||||||
unset interface
|
local interface
|
||||||
network_get_device interface "$_ifname" || interface="$_ifname"
|
network_get_device interface "$_ifname" || interface="$_ifname"
|
||||||
option_cb() {
|
|
||||||
|
# Ignore section if ifname is not provided
|
||||||
|
[ -z "$interface" ] &&
|
||||||
|
{
|
||||||
|
logger -s -t babeld "Ignoring interface section which miss ifname"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaceFile="${OTHERCONFIGDIR}/interface_$interface.conf"
|
||||||
|
echo "interface $interface" > "$interfaceFile"
|
||||||
|
|
||||||
|
option_cb()
|
||||||
|
{
|
||||||
local option="$1"
|
local option="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
local _interface
|
|
||||||
# "option ifname" is a special option, don't actually
|
# "option ifname" is a special option, don't actually
|
||||||
# generate configuration for it.
|
# generate configuration for it.
|
||||||
[ "$option" = "ifname" ] && return
|
[ "$option" == "ifname" ] && return
|
||||||
[ -n "$interface" ] && _interface="interface $interface" || _interface="default"
|
echo "$(cat $interfaceFile) ${option//_/-} $value" > "$interfaceFile"
|
||||||
cfg_append "$_interface ${option//_/-} $value"
|
}
|
||||||
}
|
}
|
||||||
# Handle ignore options.
|
|
||||||
local _ignored
|
|
||||||
# This works because we loaded the whole configuration
|
|
||||||
# beforehand (see config_load below).
|
|
||||||
config_get_bool _ignored "$section" 'ignore' 0
|
|
||||||
if [ "$_ignored" -eq 1 ]
|
|
||||||
then
|
|
||||||
option_cb() { return; }
|
|
||||||
else
|
|
||||||
# Also include an empty "interface $interface" statement,
|
|
||||||
# so that babeld operates on this interface.
|
|
||||||
[ -n "$interface" ] && cfg_append "interface $interface"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Don't use reset_cb, this would also reset config_cb
|
# Don't use reset_cb, this would also reset config_cb
|
||||||
|
|
Loading…
Reference in a new issue