mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-13 11:34:31 +02:00
Merge branch 'checksums' into next
This commit is contained in:
commit
b43b1b3955
1 changed files with 22 additions and 3 deletions
|
@ -1150,6 +1150,14 @@
|
||||||
:local ReloadGlobalConfig false;
|
:local ReloadGlobalConfig false;
|
||||||
:local DeviceMode [ /system/device-mode/get ];
|
:local DeviceMode [ /system/device-mode/get ];
|
||||||
|
|
||||||
|
:local CheckSums ({});
|
||||||
|
:do {
|
||||||
|
:local Url ($ScriptUpdatesBaseUrl . "checksums.json" . $ScriptUpdatesUrlSuffix);
|
||||||
|
$LogPrint debug $0 ("Fetching checksums from url: " . $Url);
|
||||||
|
:set CheckSums [ :deserialize from=json ([ /tool/fetch check-certificate=yes-without-crl \
|
||||||
|
http-header-field=({ [ $FetchUserAgentStr $0 ] }) $Url output=user as-value ]->"data") ];
|
||||||
|
} on-error={ }
|
||||||
|
|
||||||
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={
|
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={
|
||||||
:local ScriptVal [ /system/script/get $Script ];
|
:local ScriptVal [ /system/script/get $Script ];
|
||||||
:local ScriptInfo [ $ParseKeyValueStore ($ScriptVal->"comment") ];
|
:local ScriptInfo [ $ParseKeyValueStore ($ScriptVal->"comment") ];
|
||||||
|
@ -1163,7 +1171,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if (!($ScriptInfo->"ignore" = true)) do={
|
:do {
|
||||||
|
:if ($ScriptInfo->"ignore" = true) do={
|
||||||
|
$LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested.");
|
||||||
|
:error true;
|
||||||
|
}
|
||||||
|
|
||||||
|
: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;
|
||||||
|
}
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
:local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ];
|
:local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ];
|
||||||
:local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ];
|
:local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ];
|
||||||
|
@ -1182,10 +1202,9 @@
|
||||||
} else={
|
} else={
|
||||||
$LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!");
|
$LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!");
|
||||||
}
|
}
|
||||||
|
:error false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
:do {
|
|
||||||
: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;
|
:error false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue