Hi, I'm working on a (Freifunk) network setup based on Linux and Bird using an OSPF/iBGP configuration which basicly works like a charm. Now I have some setups where multiple prefixes are configured on a node either for connected networks or for some anycasted ressources. To be able to enable/disable exporting these prefixes separately base on different criteria (probaly by different check scripts trigger by cron or something like this) I thought about options to realize this. All my configuration is centrally managed by Salt and some mighty templates. My first though was to have something like the following in the global configuration define SITE_LEGACY_ONLINE = 0; define SITE_PADCTY_ONLINE = 0; define SITE_PADUML_ONLINE = 0; define DRAINED = 0; an later re-set these values to 0 in separate config files which are automagically generated by some script of other means. Thereby I can have useful defaults and only when a check rules for a positive outcome a SITE would go online (read: the prefix would be announed). Any I make sure the configuration as a whole is useful all the time. Now I tried to just reset a value like SITE_LEGACY_ONLINE = 1; or define SITE_LEGACY_ONLINE = 1; later in the configuration but both raise configuration errors (as I was afraid they would). Are there any means to build something like that? Like having some defaults in the main config and re-set these values later on (in other config snippets)? If I would generate the defines by a script I would have some time where this part might be missing (like on first install) and my config would fail to load as the defines are referenced but not defined. Thanks for any ideas how to build something like that. :) Best Max -- "Wer nicht mehr liebt und nicht mehr irrt, der lasse sich begraben." -- Johann Wolfgang von Goethe
On Wed, Jan 18, 2017 at 06:20:53PM +0100, Maximilian Wilhelm wrote:
Hi,
Are there any means to build something like that? Like having some defaults in the main config and re-set these values later on (in other config snippets)? If I would generate the defines by a script I would have some time where this part might be missing (like on first install) and my config would fail to load as the defines are referenced but not defined.
Hi Yes, defines are constants. There are some ugly tricks how to do that [*], but i would strongly suggest just to ensure there is always a generated script with defines. Note that if the script referenced by include does not exist, config also fails. That could be avoided by using wildcard in include. [*] e.g. use function variables instead of constants: function get_val() int val; { val = 0; include "val.conf*"; return val; } or use that include may appear inside of expressions: define val = (1 ~ [ include "val.conf*"; 0 ]); (val is either false or true, depending of whether it expands to 1 ~ [0] or 1 ~ [1, 0]; you would have to add comma to the value in included file) -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
participants (2)
-
Maximilian Wilhelm -
Ondrej Zajicek