mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
introduce global-config-overlay
This commit is contained in:
parent
2258087aab
commit
1cee36a911
7 changed files with 41 additions and 17 deletions
14
README.md
14
README.md
|
@ -26,7 +26,7 @@ Initial setup
|
||||||
|
|
||||||
If you know how things work just copy and paste the
|
If you know how things work just copy and paste the
|
||||||
[initial commands](initial-commands). Remember to edit and rerun
|
[initial commands](initial-commands). Remember to edit and rerun
|
||||||
`global-config`!
|
`global-config-overlay`!
|
||||||
First time useres should take the long way below.
|
First time useres should take the long way below.
|
||||||
|
|
||||||
### Live presentation
|
### 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.
|
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
|
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.
|
And finally load configuration and functions and add the scheduler.
|
||||||
|
|
||||||
[admin@MikroTik] > / system script run global-config
|
[admin@MikroTik] > / system script { run global-config; run global-config-overlay; run global-functions; }
|
||||||
[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-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-functions; }"
|
|
||||||
|
|
||||||
Updating scripts
|
Updating scripts
|
||||||
----------------
|
----------------
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
:global GlobalConfigVersion 8;
|
:global GlobalConfigVersion 9;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
|
18
global-config-overlay
Normal file
18
global-config-overlay
Normal file
|
@ -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.
|
||||||
|
|
|
@ -11,4 +11,5 @@
|
||||||
6="introduced script 'upload-backup' with new configuration parameters";
|
6="introduced script 'upload-backup' with new configuration parameters";
|
||||||
7="introduced script 'check-health' with new configuration parameters";
|
7="introduced script 'check-health' with new configuration parameters";
|
||||||
8="added donation hint and option to silence it";
|
8="added donation hint and option to silence it";
|
||||||
|
9="introduced configuration overlay 'global-config-overlay'";
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# global functions
|
# global functions
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 8;
|
:global ExpectedConfigVersion 9;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global SentConfigChangesNotification "-";
|
:global SentConfigChangesNotification "-";
|
||||||
|
|
|
@ -15,12 +15,9 @@
|
||||||
:error "Anything is wrong with your certificates!";
|
:error "Anything is wrong with your certificates!";
|
||||||
}
|
}
|
||||||
/ file remove "letsencrypt.pem";
|
/ 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 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 {
|
/ system script { run global-config; run global-config-overlay; run global-functions; }
|
||||||
run global-config;
|
/ system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-config-overlay; run global-functions; }"
|
||||||
run global-functions;
|
|
||||||
}
|
|
||||||
/ system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-functions; }"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@
|
||||||
:log info ("Updating script: " . $ScriptVal->"name");
|
:log info ("Updating script: " . $ScriptVal->"name");
|
||||||
/ system script set owner=($ScriptVal->"name") source=$SourceNew \
|
/ system script set owner=($ScriptVal->"name") source=$SourceNew \
|
||||||
dont-require-permissions=$DontRequirePermissions $Script;
|
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={
|
:if ($ScriptVal->"name" = "global-functions") do={
|
||||||
/ system script run global-functions;
|
/ system script run global-functions;
|
||||||
}
|
}
|
||||||
|
@ -82,10 +86,14 @@
|
||||||
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
||||||
:global GlobalConfigChanges;
|
:global GlobalConfigChanges;
|
||||||
:local ChangeLogCode;
|
: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 . \
|
: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 . \
|
"variable GlobalConfigVersion (currently " . $GlobalConfigVersion . \
|
||||||
") to " . $ExpectedConfigVersion . " and re-run global-config.");
|
") to " . $ExpectedConfigVersion . " and re-run " . $ConfigScript . ".");
|
||||||
|
|
||||||
:log debug ("Fetching changelog.");
|
:log debug ("Fetching changelog.");
|
||||||
:do {
|
:do {
|
||||||
|
|
Loading…
Reference in a new issue