aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-09-03 20:59:00 +0200
committerGravatar Christian Hesse <mail@eworm.de>2019-09-12 21:29:41 +0200
commit1cee36a911ef20374cbafc989a5d3699c3fc0def (patch)
treed4198905fdfa5c848a462d5dcac6afb25628a4d3
parent2258087aab5c94a3970685f7f25587ed5403111d (diff)
introduce global-config-overlaychange-9
-rw-r--r--README.md14
-rw-r--r--global-config2
-rw-r--r--global-config-overlay18
-rw-r--r--global-config.changes1
-rw-r--r--global-functions2
-rw-r--r--initial-commands9
-rw-r--r--script-updates12
7 files changed, 41 insertions, 17 deletions
diff --git a/README.md b/README.md
index 3165684..629b7a8 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Initial setup
If you know how things work just copy and paste the
[initial commands](initial-commands). Remember to edit and rerun
-`global-config`!
+`global-config-overlay`!
First time useres should take the long way below.
### Live presentation
@@ -85,18 +85,18 @@ crap and a good example how to *not* do it.
Now let's download the main scripts and add them in configuration on the fly.
- [admin@MikroTik] > :foreach Script in={ "global-config"; "global-functions"; "script-updates" } do={ / system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script) output=user as-value]->"data"); }
+ [admin@MikroTik] > :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions"; "script-updates" } do={ / system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script) output=user as-value]->"data"); }
The configuration needs to be tweaked for your needs. Make sure not to send
-your mails to `mail@example.com`!
+your mails to `mail@example.com`! Edit `global-config-overlay`, copy
+configuration from `global-config`.
- [admin@MikroTik] > / system script edit global-config source
+ [admin@MikroTik] > / system script edit global-config-overlay source
And finally load configuration and functions and add the scheduler.
- [admin@MikroTik] > / system script run global-config
- [admin@MikroTik] > / system script run global-functions
- [admin@MikroTik] > / system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-functions; }"
+ [admin@MikroTik] > / system script { run global-config; run global-config-overlay; run global-functions; }
+ [admin@MikroTik] > / system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-config-overlay; run global-functions; }"
Updating scripts
----------------
diff --git a/global-config b/global-config
index 85a4232..7a2787a 100644
--- a/global-config
+++ b/global-config
@@ -6,7 +6,7 @@
# Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'!
-:global GlobalConfigVersion 8;
+:global GlobalConfigVersion 9;
# This is used for DNS and backup file.
:global Domain "example.com";
diff --git a/global-config-overlay b/global-config-overlay
new file mode 100644
index 0000000..c1971db
--- /dev/null
+++ b/global-config-overlay
@@ -0,0 +1,18 @@
+#!rsc
+# RouterOS script: global-config-overlay
+# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
+#
+# global configuration, custom overlay
+
+# Make sure all configuration properties are up to date and this
+# value is in sync with value in script 'global-functions'!
+:global GlobalConfigVersion 9;
+
+# The global-config script is updated by script-updates,
+# global-config-overlay becomes an overlay for your changes.
+:global ScriptUpdatesIgnore {
+ "global-config-overlay"
+}
+
+# Copy configuration from global-config here and modify it.
+
diff --git a/global-config.changes b/global-config.changes
index 4951996..98c8a2c 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -11,4 +11,5 @@
6="introduced script 'upload-backup' with new configuration parameters";
7="introduced script 'check-health' with new configuration parameters";
8="added donation hint and option to silence it";
+ 9="introduced configuration overlay 'global-config-overlay'";
};
diff --git a/global-functions b/global-functions
index 371c230..e50c61e 100644
--- a/global-functions
+++ b/global-functions
@@ -6,7 +6,7 @@
# global functions
# expected configuration version
-:global ExpectedConfigVersion 8;
+:global ExpectedConfigVersion 9;
# global variables not to be changed by user
:global SentConfigChangesNotification "-";
diff --git a/initial-commands b/initial-commands
index 335dbad..3caed40 100644
--- a/initial-commands
+++ b/initial-commands
@@ -15,12 +15,9 @@
:error "Anything is wrong with your certificates!";
}
/ file remove "letsencrypt.pem";
- :foreach Script in={ "global-config"; "global-functions"; "script-updates" } do={
+ :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions"; "script-updates" } do={
/ system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script) output=user as-value]->"data");
}
- / system script {
- run global-config;
- run global-functions;
- }
- / system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-functions; }"
+ / system script { run global-config; run global-config-overlay; run global-functions; }
+ / system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-config-overlay; run global-functions; }"
}
diff --git a/script-updates b/script-updates
index de8bf40..8b70a98 100644
--- a/script-updates
+++ b/script-updates
@@ -63,6 +63,10 @@
:log info ("Updating script: " . $ScriptVal->"name");
/ system script set owner=($ScriptVal->"name") source=$SourceNew \
dont-require-permissions=$DontRequirePermissions $Script;
+ :if ($ScriptVal->"name" = "global-config" && \
+ [ / system script print count-only where name="global-config-overlay" ] > 0) do={
+ / system script { run global-config; run global-config-overlay; }
+ }
:if ($ScriptVal->"name" = "global-functions") do={
/ system script run global-functions;
}
@@ -82,10 +86,14 @@
$GlobalConfigVersion < $ExpectedConfigVersion) do={
:global GlobalConfigChanges;
:local ChangeLogCode;
+ :local ConfigScript "global-config";
+ :if ([ /system script print count-only where name="global-config-overlay" ] > 0) do={
+ :set ConfigScript "global-config-overlay";
+ }
:local NotificationMessage ("Current configuration on " . $Identity . \
- " is out of date. Please update global-config, then increase " . \
+ " is out of date. Please update " . $ConfigScript . ", then increase " . \
"variable GlobalConfigVersion (currently " . $GlobalConfigVersion . \
- ") to " . $ExpectedConfigVersion . " and re-run global-config.");
+ ") to " . $ExpectedConfigVersion . " and re-run " . $ConfigScript . ".");
:log debug ("Fetching changelog.");
:do {