Commit 1cee36a9 authored by Christian Hesse's avatar Christian Hesse

introduce global-config-overlay

parent 2258087a
......@@ -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
----------------
......
......@@ -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";
......
#!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.
......@@ -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'";
};
......@@ -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 "-";
......
......@@ -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; }"
}
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment