babeld: Support default interface configuration
authorBaptiste Jonglez <baptiste--git@jonglez.org>
Fri, 29 Aug 2014 06:51:29 +0000 (08:51 +0200)
committerBaptiste Jonglez <baptiste--git@jonglez.org>
Fri, 29 Aug 2014 08:19:42 +0000 (10:19 +0200)
When a "section interface" does not have a "option ifname", all its
options are used as default interface options.

babeld/files/babeld.init

index cb98e391d9519fcdda0b50dd6c62b39b2f2e0536..d6a6f1ea264fba31ea4814e5f64105fef3794656 100755 (executable)
@@ -110,10 +110,12 @@ babel_config_cb() {
                option_cb() {
                        local option="$1"
                        local value="$2"
+                       local _interface
                        # "option ifname" is a special option, don't actually
                        # generate configuration for it.
                        [ "$option" = "ifname" ] && return
-                       cfg_append "interface $interface ${option//_/-} $value"
+                       [ -n "$interface" ] && _interface="interface $interface" || _interface="default"
+                       cfg_append "$_interface ${option//_/-} $value"
                }
                # Handle ignore options.
                local _ignored
@@ -126,7 +128,7 @@ babel_config_cb() {
                else
                        # Also include an empty "interface $interface" statement,
                        # so that babeld operates on this interface.
-                       cfg_append "interface $interface"
+                       [ -n "$interface" ] && cfg_append "interface $interface"
                fi
        ;;
        *)