aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-12-18 17:50:37 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-12-18 20:32:29 +0100
commit0360a0ef901659b7a63ba9fcdf70883b8f098e72 (patch)
tree26003d70628f5b9a143b2eae72b870831c321f3c
parent40dc2415d3c414d77f31084936040d586d8c8acb (diff)
global-functions: $ScriptInstallUpdate: implement migration mechanismchange-41
Reset $SentConfigChangesNotification and rerun $ScriptInstallUpdate to test... :set SentConfigChangesNotification $ScriptInstallUpdate
-rw-r--r--global-config2
-rw-r--r--global-config-overlay2
-rw-r--r--global-config.changes6
-rw-r--r--global-functions9
4 files changed, 16 insertions, 3 deletions
diff --git a/global-config b/global-config
index c1f5ec5..379701a 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 40;
+:global GlobalConfigVersion 41;
# This is used for DNS and backup file.
:global Domain "example.com";
diff --git a/global-config-overlay b/global-config-overlay
index aa22167..a7cd500 100644
--- a/global-config-overlay
+++ b/global-config-overlay
@@ -9,7 +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 40;
+:global GlobalConfigVersion 41;
# Copy configuration from global-config here and modify it.
diff --git a/global-config.changes b/global-config.changes
index 3c06553..2d53160 100644
--- a/global-config.changes
+++ b/global-config.changes
@@ -44,4 +44,10 @@
38="Imported new Let's Encrypt intermediate certificate 'R3'.";
39="Added support for interface specific address list entries in 'ipv6-update'.";
40="Made the certificate renewal time configurable.";
+ 41="Implemented migration mechanism for script updates.";
+};
+
+# Migration steps to be applied on script updates
+:global GlobalConfigMigration {
+ 41=":global SendNotification; \$SendNotification (\"Migration mechanism\") (\"Congratulations!\nSuccessfully tested the new migration mechanism.\");";
};
diff --git a/global-functions b/global-functions
index 9ee2d00..e1a7d3d 100644
--- a/global-functions
+++ b/global-functions
@@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
-:global ExpectedConfigVersion 40;
+:global ExpectedConfigVersion 41;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
@@ -659,6 +659,7 @@
:if ($SentConfigChangesNotification!=$ExpectedConfigVersion && \
$GlobalConfigVersion < $ExpectedConfigVersion) do={
:global GlobalConfigChanges;
+ :global GlobalConfigMigration;
:local ChangeLogCode;
:local ConfigScript "global-config";
:if ([ :len [ / system script find where name="global-config-overlay" ] ] > 0) do={
@@ -684,8 +685,14 @@
:set NotificationMessage ($NotificationMessage . \
"\n * " . $GlobalConfigChanges->[ :tostr $I ]);
$LogPrintExit info ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
+ :local Migration ($GlobalConfigMigration->[ :tostr $I ]);
+ :if ([ :typeof $Migration ] = "str") do={
+ $LogPrintExit info ("Applying migration: " . $Migration) false;
+ [ :parse $Migration ];
+ }
}
:set GlobalConfigChanges;
+ :set GlobalConfigMigration;
} on-error={
$LogPrintExit warning ("Failed fetching changes!") false;
:set NotificationMessage ($NotificationMessage . \