mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-17 02:29:38 +00:00
global-functions: $ScriptInstallUpdate: use :continue in loop
This commit is contained in:
parent
82e6e30b12
commit
f752feb79c
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/stargazers)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||||
[](https://mikrotik.com/download/changelogs/)
|
[](https://mikrotik.com/download/changelogs/)
|
||||||
[](https://t.me/routeros_scripts)
|
[](https://t.me/routeros_scripts)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
[](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
|
> 💡️ **Hint**: If in doubt have a look at the badge at the top of each
|
||||||
> page showing the minimum version required:
|
> page showing the minimum version required:
|
||||||
> 
|
> 
|
||||||
|
|
||||||
> ℹ️ **Info**: The `main` branch is now RouterOS v7 only. If you are still
|
> ℹ️ **Info**: The `main` branch is now RouterOS v7 only. If you are still
|
||||||
> running RouterOS v6 switch to `routeros-v6` branch!
|
> running RouterOS v6 switch to `routeros-v6` branch!
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.21
|
# requires RouterOS, version=7.22
|
||||||
#
|
#
|
||||||
# deprecated global functions
|
# deprecated global functions
|
||||||
# https://rsc.eworm.de/
|
# https://rsc.eworm.de/
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# Michael Gisbers <michael@gisbers.de>
|
# Michael Gisbers <michael@gisbers.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.21
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, fetch, scheduler
|
# requires device-mode, fetch, scheduler
|
||||||
#
|
#
|
||||||
# global functions
|
# global functions
|
||||||
|
|
@ -1295,17 +1295,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={
|
||||||
|
|
@ -1327,44 +1326,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, ") ] ];
|
||||||
|
|
@ -1377,12 +1376,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");
|
||||||
|
|
@ -1393,7 +1392,6 @@
|
||||||
$ScriptVal->"name" ~ ("^(global-functions\\.d|mod)/.")) do={
|
$ScriptVal->"name" ~ ("^(global-functions\\.d|mod)/.")) do={
|
||||||
:set ReloadGlobal true;
|
:set ReloadGlobal true;
|
||||||
}
|
}
|
||||||
} on-error={ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($ReloadGlobal = true) do={
|
:if ($ReloadGlobal = true) do={
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue