mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $ScriptInstallUpdate: run migration unconditionally
We want the migration to run even if the notification is disabled.
This commit is contained in:
parent
9ab20bb927
commit
d1741c99fe
1 changed files with 53 additions and 42 deletions
|
@ -666,6 +666,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
:local ExpectedConfigVersionBefore $ExpectedConfigVersion;
|
||||
:local ScriptInstallUpdateBefore [ :tostr $ScriptInstallUpdate ];
|
||||
|
||||
:foreach Script in=[ / system script find where source~"^#!rsc( by RouterOS)\?\n" ] do={
|
||||
|
@ -748,18 +749,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
:if ($SentConfigChangesNotification!=$ExpectedConfigVersion && \
|
||||
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
||||
:if ($ExpectedConfigVersionBefore != $ExpectedConfigVersion) do={
|
||||
:global GlobalConfigChanges;
|
||||
:global GlobalConfigMigration;
|
||||
:local ChangeLogCode;
|
||||
:local NotificationMessage ("Current configuration on " . $Identity . \
|
||||
" is out of date. Please update global-config-overlay, then increase " . \
|
||||
"\$GlobalConfigVersion (currently " . $GlobalConfigVersion . \
|
||||
") to " . $ExpectedConfigVersion . " and re-run global-config-overlay.");
|
||||
$LogPrintExit2 info $0 ($NotificationMessage) false;
|
||||
|
||||
$LogPrintExit2 debug $0 ("Fetching changelog.") false;
|
||||
$LogPrintExit2 debug $0 ("Fetching news, changes and migration.") false;
|
||||
:do {
|
||||
:local Result [ / tool fetch check-certificate=yes-without-crl \
|
||||
($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \
|
||||
|
@ -768,37 +763,49 @@
|
|||
:set ChangeLogCode ($Result->"data");
|
||||
}
|
||||
} on-error={
|
||||
$LogPrintExit2 warning $0 ("Failed fetching changes!") false;
|
||||
:set NotificationMessage ($NotificationMessage . \
|
||||
"\n\nChanges are not available.");
|
||||
$LogPrintExit2 warning $0 ("Failed fetching news, changes and migration!") false;
|
||||
}
|
||||
|
||||
:if ([ :len $ChangeLogCode ] > 0) do={
|
||||
:if ([ $ValidateSyntax $ChangeLogCode ] = true) do={
|
||||
:set NotificationMessage ($NotificationMessage . "\n\nChanges:");
|
||||
[ :parse $ChangeLogCode ];
|
||||
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("The changelog failed syntax validation!") false;
|
||||
}
|
||||
}
|
||||
|
||||
:if ([ :len $GlobalConfigMigration ] > 0) do={
|
||||
:for I from=($ExpectedConfigVersionBefore + 1) to=$ExpectedConfigVersion do={
|
||||
:local Migration ($GlobalConfigMigration->[ :tostr $I ]);
|
||||
:if ([ :typeof $Migration ] = "str") do={
|
||||
:if ([ $ValidateSyntax $Migration ] = true) do={
|
||||
$LogPrintExit2 info $0 ("Applying migration: " . $Migration) false;
|
||||
$LogPrintExit2 info $0 ("Applying migration for change " . $I . ": " . $Migration) false;
|
||||
[ :parse $Migration ];
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("Migration code for change " . $I . " failed syntax validation!") false;
|
||||
}
|
||||
}
|
||||
:set NotificationMessage ($NotificationMessage . \
|
||||
"\n " . [ $IfThenElse ($NotificationsWithSymbols = true) ("\E2\97\8F") "*" ] . " " . \
|
||||
$GlobalConfigChanges->[ :tostr $I ]);
|
||||
$LogPrintExit2 info $0 ("Change: " . $GlobalConfigChanges->[ :tostr $I ]) false;
|
||||
}
|
||||
:set GlobalConfigChanges;
|
||||
:set GlobalConfigMigration;
|
||||
}
|
||||
|
||||
:if ($SentConfigChangesNotification != $ExpectedConfigVersion && \
|
||||
$GlobalConfigVersion < $ExpectedConfigVersion) do={
|
||||
:local NotificationMessage ("Current configuration on " . $Identity . \
|
||||
" is out of date. Please update global-config-overlay, then increase " . \
|
||||
"\$GlobalConfigVersion (currently " . $GlobalConfigVersion . \
|
||||
") to " . $ExpectedConfigVersion . " and re-run global-config-overlay.");
|
||||
$LogPrintExit2 info $0 ($NotificationMessage) false;
|
||||
|
||||
:if ([ :len $GlobalConfigChanges ] > 0) do={
|
||||
:set NotificationMessage ($NotificationMessage . "\n\nChanges:");
|
||||
:for I from=($GlobalConfigVersion + 1) to=$ExpectedConfigVersion do={
|
||||
:local Change ($GlobalConfigChanges->[ :tostr $I ]);
|
||||
:set NotificationMessage ($NotificationMessage . "\n " . \
|
||||
[ $IfThenElse ($NotificationsWithSymbols = true) ("\E2\97\8F") "*" ] . " " . $Change);
|
||||
$LogPrintExit2 info $0 ("Change " . $I . ": " . $Change) false;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("The changelog failed syntax validation!") false;
|
||||
:set NotificationMessage ($NotificationMessage . \
|
||||
"\n\nChanges are not available.");
|
||||
}
|
||||
:set NotificationMessage ($NotificationMessage . "\n\nNews and changes are not available.");
|
||||
}
|
||||
|
||||
:local Link;
|
||||
|
@ -816,6 +823,10 @@
|
|||
:set SentConfigChangesNotification $ExpectedConfigVersion;
|
||||
}
|
||||
|
||||
:set GlobalConfigChanges;
|
||||
:set GlobalConfigMigration;
|
||||
}
|
||||
|
||||
:if ($ScriptInstallUpdateBefore != [ :tostr $ScriptInstallUpdate ]) do={
|
||||
$LogPrintExit2 info $0 ("This function changed, you may want to re-run.") false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue