global-config: support loading snippets

This adds support for loading snippets, which need a name starting with
"global-config-overlay.d/". This allows to split off configuration if
desired.
This commit is contained in:
Christian Hesse 2024-03-08 09:33:17 +01:00
parent e39e8a0083
commit a7cb3e520a
4 changed files with 17 additions and 1 deletions

View File

@ -139,6 +139,11 @@ Save changes and exit with `Ctrl-o`.
![screenshot: edit global-config-overlay](README.d/07-edit-global-config-overlay.avif)
Additionally creating configuration snippets is supported. The script name
of these snippets has to start with `global-config-overlay.d/` to make them
being loaded automatically. This allows to split off parts of the
configuration.
To apply your changes run `global-config`, which will automatically load
the overlay as well:

View File

@ -250,3 +250,13 @@
} on-error={
:log error ("Loading configuration from overlay failed!");
}
# configuration overlay snippets
:foreach Script in=[ /system/script/find where name ~ "^global-config-overlay.d/" ] do={
:do {
/system/script/run $Script;
} on-error={
:log error ("Loading configuration from overlay snippet " . \
[ /system/script/get $Script name ] . " failed!");
}
}

View File

@ -12,7 +12,7 @@
:local ScriptName [ :jobname ];
# expected configuration version
:global ExpectedConfigVersion 121;
:global ExpectedConfigVersion 122;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View File

@ -46,6 +46,7 @@
119="Added support for IPv6 to script 'fw-addr-lists'.";
120="Implemented a workaround in 'backup-cloud'. Now script should no longer just crash, but send notification with error.";
121="The 'wifiwave2' scripts are finally gone. Development continues with 'wifi' in RouterOS 7.13 and later.";
122="The global configuration was enhanced to support loading snippets. Configuration can be split off to scripts where name starts with 'global-config-overlay.d/'.";
};
# Migration steps to be applied on script updates