mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-16 18:19:36 +00:00
global-functions: $ScriptInstallUpdate: use :continue in loop
This commit is contained in:
parent
051ae0f654
commit
30aeef1707
3 changed files with 15 additions and 17 deletions
|
|
@ -4,7 +4,7 @@ RouterOS Scripts
|
|||
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||
[](https://mikrotik.com/download/changelogs/)
|
||||
[](https://mikrotik.com/download/changelogs/)
|
||||
[](https://t.me/routeros_scripts)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ temporarily.
|
|||
|
||||
> 💡️ **Hint**: If in doubt have a look at the badge at the top of each
|
||||
> page showing the minimum version required:
|
||||
> 
|
||||
> 
|
||||
|
||||
> ℹ️ **Info**: The `main` branch is now RouterOS v7 only. If you are still
|
||||
> running RouterOS v6 switch to `routeros-v6` branch!
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.21
|
||||
# requires RouterOS, version=7.22
|
||||
#
|
||||
# deprecated global functions
|
||||
# https://rsc.eworm.de/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# Michael Gisbers <michael@gisbers.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.21
|
||||
# requires RouterOS, version=7.22
|
||||
# requires device-mode, fetch, scheduler
|
||||
#
|
||||
# global functions
|
||||
|
|
@ -1295,17 +1295,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
:do {
|
||||
:if ($ScriptInfo->"ignore" = true) do={
|
||||
$LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested.");
|
||||
:error true;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local CheckSum ($CheckSums->($ScriptVal->"name"));
|
||||
:if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \
|
||||
[ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={
|
||||
$LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring.");
|
||||
:error true;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:if ([ :len ($ScriptInfo->"certificate") ] > 0) do={
|
||||
|
|
@ -1327,44 +1326,44 @@
|
|||
} do={
|
||||
$LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err);
|
||||
:if ($Err != "Fetch failed with status 404") do={
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={
|
||||
$LogPrint warning $0 ("Removing dummy. Typo on installation?");
|
||||
/system/script/remove $Script;
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
:if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \
|
||||
[ :len $CheckSum ] = 0) do={
|
||||
$LogPrintOnce warning $0 \
|
||||
("Added the script manually? Skip updates with 'ignore=true' in comment.");
|
||||
}
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:if ([ :len $SourceNew ] = 0) do={
|
||||
$LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'.");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local SourceCRLF [ :tocrlf $SourceNew ];
|
||||
:if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={
|
||||
$LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change.");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={
|
||||
$LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \
|
||||
"' is not valid (missing shebang). Ignoring!");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version");
|
||||
:if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={
|
||||
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \
|
||||
$RequiredROS . ", which is not met by your installation. Ignoring!");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ];
|
||||
|
|
@ -1377,12 +1376,12 @@
|
|||
:if ([ :len $MissingDM ] > 0) do={
|
||||
$LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \
|
||||
"device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
:if ([ $ValidateSyntax $SourceNew ] = false) do={
|
||||
$LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!");
|
||||
:error false;
|
||||
:continue;
|
||||
}
|
||||
|
||||
$LogPrint info $0 ("Updating script: " . $ScriptVal->"name");
|
||||
|
|
@ -1393,7 +1392,6 @@
|
|||
$ScriptVal->"name" ~ ("^(global-functions\\.d|mod)/.")) do={
|
||||
:set ReloadGlobal true;
|
||||
}
|
||||
} on-error={ }
|
||||
}
|
||||
|
||||
:if ($ReloadGlobal = true) do={
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue