aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-08 09:33:17 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 20:36:21 +0100
commita7cb3e520a86b44cb6e1bdfdf6df24856274e0e3 (patch)
tree6527b4ebc820bc63e80687333ae4eee3399a1e45
parente39e8a00834192211999b89f5f163a35c2214707 (diff)
global-config: support loading snippetschange-122
This adds support for loading snippets, which need a name starting with "global-config-overlay.d/". This allows to split off configuration if desired.
-rw-r--r--README.md5
-rw-r--r--global-config.rsc10
-rw-r--r--global-functions.rsc2
-rw-r--r--news-and-changes.rsc1
4 files changed, 17 insertions, 1 deletions
diff --git a/README.md b/README.md
index 1af718c..61b1725 100644
--- a/README.md
+++ b/README.md
@@ -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:
diff --git a/global-config.rsc b/global-config.rsc
index 983eedb..85731c3 100644
--- a/global-config.rsc
+++ b/global-config.rsc
@@ -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!");
+ }
+}
diff --git a/global-functions.rsc b/global-functions.rsc
index 7f5ba9f..d2386f4 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -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;
diff --git a/news-and-changes.rsc b/news-and-changes.rsc
index c5117ca..46b777a 100644
--- a/news-and-changes.rsc
+++ b/news-and-changes.rsc
@@ -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