From f4d6e07dbb6c1406b56c77116a52d11ff8b363b1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 14 Jul 2020 16:32:17 +0200 Subject: global-config: dropped $ScriptUpdatesIgnore, use ignore flag in comment --- INITIAL-COMMANDS.md | 3 ++- README.md | 4 ++++ global-config | 6 ++---- global-config-overlay | 8 +------- global-config.changes | 1 + global-functions | 18 +++++++++++++----- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 4541430..c985f9c 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -17,8 +17,9 @@ procedure please follow [the long way in detail](README.md#the-long-way-in-detai :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } 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 set comment="ignore" global-config-overlay; / 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; }" + / system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-config-overlay; run global-functions; }"; $CertificateNameByCN "ISRG Root X1"; $CertificateNameByCN "Let's Encrypt Authority X3"; $CertificateNameByCN "DST Root CA X3"; diff --git a/README.md b/README.md index 54473c3..99fbdc5 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ Now let's download the main scripts and add them in configuration on the fly. [admin@MikroTik] > :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } 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"); } +Mark `global-config-overlay` not to be overwritten by future updates. + + [admin@MikroTik] > / system script set comment="ignore" global-config-overlay + The configuration needs to be tweaked for your needs. Make sure not to send your mails to `mail@example.com`! Edit `global-config-overlay`, copy configuration from `global-config`. diff --git a/global-config b/global-config index bd82a19..0e4ae63 100644 --- a/global-config +++ b/global-config @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 21; +:global GlobalConfigVersion 22; # This is used for DNS and backup file. :global Domain "example.com"; @@ -111,9 +111,7 @@ #:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/master/"; #:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/master/"; :global ScriptUpdatesUrlSuffix ""; -:global ScriptUpdatesIgnore { - "global-config" -} + # This project is developed in private spare time and usage is free of charge # for you. If you like the scripts and think this is of value for you or your # business please consider a donation: diff --git a/global-config-overlay b/global-config-overlay index d143efa..22d3ab5 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -9,13 +9,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! # Comment or remove to disable change notifications. -:global GlobalConfigVersion 21; - -# The global-config script is updated by $ScriptInstallUpdate, -# global-config-overlay becomes an overlay for your changes. -:global ScriptUpdatesIgnore { - "global-config-overlay" -} +:global GlobalConfigVersion 22; # Copy configuration from global-config here and modify it. diff --git a/global-config.changes b/global-config.changes index 4e6fcfc..f6a0c40 100644 --- a/global-config.changes +++ b/global-config.changes @@ -25,4 +25,5 @@ 19="Commenting scripts with 'ignore', 'base-url=...' and 'url-suffix=...' is honored on update"; 20="Added support for hooks to 'netwatch-notify'"; 21="Added support for installing patch updates automatically by 'check-routeros-update'"; + 22="Dropped '\$ScriptUpdatesIgnore' from global configuration, auto-migrating to ignore flag in comment" }; diff --git a/global-functions b/global-functions index 57ae336..db27774 100644 --- a/global-functions +++ b/global-functions @@ -8,7 +8,7 @@ # https://git.eworm.de/cgit/routeros-scripts/about/ # expected configuration version -:global ExpectedConfigVersion 21; +:global ExpectedConfigVersion 22; # global variables not to be changed by user :global GlobalFunctionsReady false; @@ -529,11 +529,19 @@ } :if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={ - :foreach IgnoreLoop in=$ScriptUpdatesIgnore do={ - :if ($IgnoreLoop = $ScriptVal->"name") do={ :set Ignore 1; } - } :local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ]; - :if ($Comment->"ignore" = true) do={ :set Ignore 1; } + :if ($Comment->"ignore" = true) do={ + :set Ignore 1; + } else={ + # TODO: remove at later time + :foreach IgnoreLoop in=$ScriptUpdatesIgnore do={ + :if ($IgnoreLoop = $ScriptVal->"name") do={ + :set Ignore 1; + $LogPrintExit info ("Migrating script " . $ScriptVal->"name" . " to ignore flag in comment.") false; + / system script set comment="ignore" ($ScriptVal->"name"); + } + } + } :if ($Ignore = 0) do={ $LogPrintExit debug ("Fetching script from url: " . $ScriptVal->"name") false; -- cgit v1.2.3-54-g00ecf