summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Kerneis2015-05-21 08:31:34 +0000
committerMarkus Stenberg2015-05-21 08:44:19 +0000
commitac643416dc6065554066574f147def8134556474 (patch)
treee839a2182b66b749786db56559b770df2ae680a3
parentb39fa42c62232ae9c5db8d2213dd740394c0fed0 (diff)
downloadrouting-ac643416dc6065554066574f147def8134556474.tar.gz
babeld: allow changing alternative configuration file and directory
Signed-off-by: Gabriel Kerneis <kerneis@google.com> Signed-off-by: Markus Stenberg <markus.stenberg@iki.fi>
-rw-r--r--babeld/files/babeld.config14
-rwxr-xr-xbabeld/files/babeld.init9
2 files changed, 17 insertions, 6 deletions
diff --git a/babeld/files/babeld.config b/babeld/files/babeld.config
index fa22fd6..cb2a131 100644
--- a/babeld/files/babeld.config
+++ b/babeld/files/babeld.config
@@ -1,10 +1,10 @@
package babeld
-# Configuration set in this file ends up in /var/etc/babeld.conf.
-# Babeld is told to use both /etc/babeld.conf and /var/etc/babeld.conf, so
-# you can use one or the other, or even both at the same time. If an
-# option is defined in both files, the version in /var/etc/babeld.conf
-# takes precedence.
+# Babeld reads options from the following files (the last one takes precedence
+# if an option is defined in several places):
+# - the file defined by the option conf_file (default: /etc/babeld.conf),
+# - *.conf files in the directory defined by conf_dir (default: /tmp/babel.d/),
+# - this UCI configuration file.
# See "man babeld" for all available options ("Global options").
# Important: remember to use '_' instead of '-' in option names.
@@ -20,6 +20,10 @@ config general
## import-table statement, "option import_table 42" should work.
# list 'import_table' '42'
# list 'import_table' '100'
+ ## Alternative configuration file and directory.
+ ## See comment at the top of this file for more details.
+ # option 'conf_file' '/etc/babeld.conf'
+ # option 'conf_dir' '/tmp/babel.d/'
config interface
## Remove this line to enable babeld on this interface
diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init
index 797ba2f..6796a34 100755
--- a/babeld/files/babeld.init
+++ b/babeld/files/babeld.init
@@ -13,7 +13,7 @@ EXTRA_HELP=" status Dump Babel's table to the log file."
# Options to ignore for the global section (old options that are translated
# for backward compatibility with old configuration files)
-ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id multicast_address port hello_interval wired_hello_interval smoothing_half_time duplication_priority local_server conf_file"
+ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id multicast_address port hello_interval wired_hello_interval smoothing_half_time duplication_priority local_server conf_file conf_dir"
# Append a line to the configuration file
cfg_append() {
@@ -109,6 +109,13 @@ parse_old_global_options() {
[ "$_bool" -eq 1 ] && add_default_option "wired" "false"
config_get_bool _bool "$section" 'no_split_horizon' 0
[ "$_bool" -eq 1 ] && add_default_option "split_horizon" "false"
+ # Configure alternative configuration file and directory
+ local conf_file
+ config_get conf_file "$section" "conf_file"
+ [ -n "$conf_file" ] && OTHERCONFIGFILE="$conf_file"
+ local conf_dir
+ config_get conf_dir "$section" "conf_dir"
+ [ -n "$conf_dir" ] && OTHERCONFIGDIR="$conf_dir"
}
babel_filter() {