global-functions: $ScriptInstallUpdate: reload functions just once

This commit is contained in:
Christian Hesse 2021-05-31 10:04:45 +02:00
parent 57b0f1b2dd
commit 2315d6bc59

View file

@ -709,6 +709,7 @@
} }
:local ExpectedConfigVersionBefore $ExpectedConfigVersion; :local ExpectedConfigVersionBefore $ExpectedConfigVersion;
:local ReloadGlobalFunctions false;
:local ScriptInstallUpdateBefore [ :tostr $ScriptInstallUpdate ]; :local ScriptInstallUpdateBefore [ :tostr $ScriptInstallUpdate ];
:foreach Script in=[ / system script find where source~"^#!rsc( by RouterOS)\?\n" ] do={ :foreach Script in=[ / system script find where source~"^#!rsc( by RouterOS)\?\n" ] do={
@ -768,12 +769,7 @@
} }
} }
:if ($ScriptVal->"name" ~ "^global-functions(\$|\\.d/.)") do={ :if ($ScriptVal->"name" ~ "^global-functions(\$|\\.d/.)") do={
$LogPrintExit2 info $0 ("Reloading global functions.") false; :set ReloadGlobalFunctions true;
:do {
/ system script run global-functions;
} on-error={
$LogPrintExit2 error $0 ("Reloading global functions failed!") false;
}
} }
} else={ } else={
$LogPrintExit2 warning $0 ("Syntax validation for script " . $ScriptVal->"name" . \ $LogPrintExit2 warning $0 ("Syntax validation for script " . $ScriptVal->"name" . \
@ -791,6 +787,15 @@
} }
} }
:if ($ReloadGlobalFunctions = true) do={
$LogPrintExit2 info $0 ("Reloading global functions.") false;
:do {
/ system script run global-functions;
} on-error={
$LogPrintExit2 error $0 ("Reloading global functions failed!") false;
}
}
:if ($ExpectedConfigVersionBefore != $ExpectedConfigVersion) do={ :if ($ExpectedConfigVersionBefore != $ExpectedConfigVersion) do={
:global GlobalConfigChanges; :global GlobalConfigChanges;
:global GlobalConfigMigration; :global GlobalConfigMigration;