From 0360a0ef901659b7a63ba9fcdf70883b8f098e72 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 18 Dec 2020 17:50:37 +0100 Subject: global-functions: $ScriptInstallUpdate: implement migration mechanism Reset $SentConfigChangesNotification and rerun $ScriptInstallUpdate to test... :set SentConfigChangesNotification $ScriptInstallUpdate --- global-functions | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'global-functions') 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 . \ -- cgit v1.2.3-54-g00ecf