mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-26 22:04:54 +02:00
global-functions: $ScriptInstallUpdate: implement migration mechanism
Reset $SentConfigChangesNotification and rerun $ScriptInstallUpdate to test... :set SentConfigChangesNotification $ScriptInstallUpdate
This commit is contained in:
parent
40dc2415d3
commit
0360a0ef90
4 changed files with 16 additions and 3 deletions
|
@ -8,7 +8,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 40;
|
:global GlobalConfigVersion 41;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
|
|
@ -9,7 +9,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'!
|
||||||
# Comment or remove to disable change notifications.
|
# Comment or remove to disable change notifications.
|
||||||
:global GlobalConfigVersion 40;
|
:global GlobalConfigVersion 41;
|
||||||
|
|
||||||
# Copy configuration from global-config here and modify it.
|
# Copy configuration from global-config here and modify it.
|
||||||
|
|
||||||
|
|
|
@ -44,4 +44,10 @@
|
||||||
38="Imported new Let's Encrypt intermediate certificate 'R3'.";
|
38="Imported new Let's Encrypt intermediate certificate 'R3'.";
|
||||||
39="Added support for interface specific address list entries in 'ipv6-update'.";
|
39="Added support for interface specific address list entries in 'ipv6-update'.";
|
||||||
40="Made the certificate renewal time configurable.";
|
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.\");";
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 40;
|
:global ExpectedConfigVersion 41;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
@ -659,6 +659,7 @@
|
||||||
:if ($SentConfigChangesNotification!=$ExpectedConfigVersion && \
|
:if ($SentConfigChangesNotification!=$ExpectedConfigVersion && \
|
||||||
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
||||||
:global GlobalConfigChanges;
|
:global GlobalConfigChanges;
|
||||||
|
:global GlobalConfigMigration;
|
||||||
:local ChangeLogCode;
|
:local ChangeLogCode;
|
||||||
:local ConfigScript "global-config";
|
:local ConfigScript "global-config";
|
||||||
:if ([ :len [ / system script find where name="global-config-overlay" ] ] > 0) do={
|
:if ([ :len [ / system script find where name="global-config-overlay" ] ] > 0) do={
|
||||||
|
@ -684,8 +685,14 @@
|
||||||
:set NotificationMessage ($NotificationMessage . \
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
"\n * " . $GlobalConfigChanges->[ :tostr $I ]);
|
"\n * " . $GlobalConfigChanges->[ :tostr $I ]);
|
||||||
$LogPrintExit info ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
|
$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 GlobalConfigChanges;
|
||||||
|
:set GlobalConfigMigration;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit warning ("Failed fetching changes!") false;
|
$LogPrintExit warning ("Failed fetching changes!") false;
|
||||||
:set NotificationMessage ($NotificationMessage . \
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue