global-functions: $ScriptInstallUpdate: use :continue in loop

This commit is contained in:
Christian Hesse 2026-01-19 16:08:37 +01:00
parent 57930b09fd
commit e2ba805bb0

View file

@ -1285,17 +1285,16 @@
} }
} }
:do {
:if ($ScriptInfo->"ignore" = true) do={ :if ($ScriptInfo->"ignore" = true) do={
$LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested.");
:error true; :continue;
} }
:local CheckSum ($CheckSums->($ScriptVal->"name")); :local CheckSum ($CheckSums->($ScriptVal->"name"));
:if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \ :if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \
[ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={
$LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring.");
:error true; :continue;
} }
:if ([ :len ($ScriptInfo->"certificate") ] > 0) do={ :if ([ :len ($ScriptInfo->"certificate") ] > 0) do={
@ -1317,44 +1316,44 @@
} do={ } do={
$LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err); $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err);
:if ($Err != "Fetch failed with status 404") do={ :if ($Err != "Fetch failed with status 404") do={
:error false; :continue;
} }
:if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={
$LogPrint warning $0 ("Removing dummy. Typo on installation?"); $LogPrint warning $0 ("Removing dummy. Typo on installation?");
/system/script/remove $Script; /system/script/remove $Script;
:error false; :continue;
} }
:if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \ :if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \
[ :len $CheckSum ] = 0) do={ [ :len $CheckSum ] = 0) do={
$LogPrintOnce warning $0 \ $LogPrintOnce warning $0 \
("Added the script manually? Skip updates with 'ignore=true' in comment."); ("Added the script manually? Skip updates with 'ignore=true' in comment.");
} }
:error false; :continue;
} }
:if ([ :len $SourceNew ] = 0) do={ :if ([ :len $SourceNew ] = 0) do={
$LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'.");
:error false; :continue;
} }
:local SourceCRLF [ :tocrlf $SourceNew ]; :local SourceCRLF [ :tocrlf $SourceNew ];
:if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={
$LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change.");
:error false; :continue;
} }
:if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={ :if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={
$LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \ $LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \
"' is not valid (missing shebang). Ignoring!"); "' is not valid (missing shebang). Ignoring!");
:error false; :continue;
} }
:local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); :local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version");
:if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={ :if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \
$RequiredROS . ", which is not met by your installation. Ignoring!"); $RequiredROS . ", which is not met by your installation. Ignoring!");
:error false; :continue;
} }
:local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ]; :local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ];
@ -1367,12 +1366,12 @@
:if ([ :len $MissingDM ] > 0) do={ :if ([ :len $MissingDM ] > 0) do={
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \
"device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!"); "device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!");
:error false; :continue;
} }
:if ([ $ValidateSyntax $SourceNew ] = false) do={ :if ([ $ValidateSyntax $SourceNew ] = false) do={
$LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!"); $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!");
:error false; :continue;
} }
$LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); $LogPrint info $0 ("Updating script: " . $ScriptVal->"name");
@ -1383,7 +1382,6 @@
$ScriptVal->"name" ~ ("^mod/.")) do={ $ScriptVal->"name" ~ ("^mod/.")) do={
:set ReloadGlobal true; :set ReloadGlobal true;
} }
} on-error={ }
} }
:if ($ReloadGlobal = true) do={ :if ($ReloadGlobal = true) do={