mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-29 04:19:34 +00:00
Merge branch 'continue-in-loop' into next
This commit is contained in:
commit
11ec566d91
5 changed files with 134 additions and 138 deletions
|
|
@ -169,7 +169,7 @@
|
||||||
:do {
|
:do {
|
||||||
:if ([ :len $CertRenewUrl ] = 0) do={
|
:if ([ :len $CertRenewUrl ] = 0) do={
|
||||||
$LogPrintOnce info $ScriptName ("No CertRenewUrl given.");
|
$LogPrintOnce info $ScriptName ("No CertRenewUrl given.");
|
||||||
:error false;
|
:continue;
|
||||||
}
|
}
|
||||||
$LogPrint info $ScriptName ("Attempting to renew certificate '" . ($CertVal->"name") . "'.");
|
$LogPrint info $ScriptName ("Attempting to renew certificate '" . ($CertVal->"name") . "'.");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
} else={
|
} else={
|
||||||
:set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
|
:set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
|
||||||
}
|
}
|
||||||
:do {
|
|
||||||
:local Branch;
|
:local Branch;
|
||||||
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
|
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
|
||||||
:local Net $Address;
|
:local Net $Address;
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
}
|
}
|
||||||
:set Branch [ $GetBranch $Address ];
|
:set Branch [ $GetBranch $Address ];
|
||||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||||
:error true;
|
:continue;
|
||||||
}
|
}
|
||||||
:if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
|
:if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
|
||||||
:local Net $Address;
|
:local Net $Address;
|
||||||
|
|
@ -137,15 +137,14 @@
|
||||||
:set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR);
|
:set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR);
|
||||||
:set Branch [ $GetBranch $Address ];
|
:set Branch [ $GetBranch $Address ];
|
||||||
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
||||||
:error true;
|
:continue;
|
||||||
}
|
}
|
||||||
:if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
|
:if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
|
||||||
:set Branch [ $GetBranch $Address ];
|
:set Branch [ $GetBranch $Address ];
|
||||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||||
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
||||||
:error true;
|
:continue;
|
||||||
}
|
}
|
||||||
} on-error={ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1290,17 +1290,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={
|
||||||
|
|
@ -1322,44 +1321,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, ") ] ];
|
||||||
|
|
@ -1372,12 +1371,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");
|
||||||
|
|
@ -1388,7 +1387,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={
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,15 @@
|
||||||
} do={
|
} do={
|
||||||
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
|
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
|
||||||
" failed: " . $Err);
|
" failed: " . $Err);
|
||||||
|
:continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] != "num") do={
|
||||||
|
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
|
||||||
|
($DohServer->"doh-url"));
|
||||||
|
:continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Data != false) do={
|
|
||||||
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] = "num") do={
|
|
||||||
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
|
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
|
||||||
:if ([ /certificate/settings/get crl-use ] = true) do={
|
:if ([ /certificate/settings/get crl-use ] = true) do={
|
||||||
$LogPrintOnce warning $ScriptName ("Configured to use CRL, that can cause severe issue!");
|
$LogPrintOnce warning $ScriptName ("Configured to use CRL, that can cause severe issue!");
|
||||||
|
|
@ -132,11 +137,6 @@
|
||||||
/ip/dns/cache/flush;
|
/ip/dns/cache/flush;
|
||||||
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
|
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
|
||||||
:exit;
|
:exit;
|
||||||
} else={
|
|
||||||
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
|
|
||||||
($DohServer->"doh-url"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} do={
|
} do={
|
||||||
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Trusted = true) do={
|
:if ($Trusted = true) do={
|
||||||
:local Done false;
|
|
||||||
:if ($Command = "?") do={
|
:if ($Command = "?") do={
|
||||||
$LogPrint info $ScriptName ("Sending notice for update " . $UpdateID . ".");
|
$LogPrint info $ScriptName ("Sending notice for update " . $UpdateID . ".");
|
||||||
$SendTelegram2 ({ origin=$ScriptName; chatid=($Chat->"id"); silent=true; \
|
$SendTelegram2 ({ origin=$ScriptName; chatid=($Chat->"id"); silent=true; \
|
||||||
|
|
@ -123,9 +122,9 @@
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
message=([ $IfThenElse ([ :len ($From->"first_name") ] > 0) ("Hello " . ($From->"first_name") . "!\n\n") ] . \
|
message=([ $IfThenElse ([ :len ($From->"first_name") ] > 0) ("Hello " . ($From->"first_name") . "!\n\n") ] . \
|
||||||
"Online" . [ $IfThenElse $TelegramChatActive " (and active!)" ] . ", awaiting your commands!") });
|
"Online" . [ $IfThenElse $TelegramChatActive " (and active!)" ] . ", awaiting your commands!") });
|
||||||
:set Done true;
|
:continue;
|
||||||
}
|
}
|
||||||
:if ($Done = false && [ :pick $Command 0 1 ] = "!") do={
|
:if ([ :pick $Command 0 1 ] = "!") do={
|
||||||
:if ($Command ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
|
:if ($Command ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
|
||||||
:set TelegramChatActive true;
|
:set TelegramChatActive true;
|
||||||
} else={
|
} else={
|
||||||
|
|
@ -133,9 +132,9 @@
|
||||||
}
|
}
|
||||||
$LogPrint info $ScriptName ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
|
$LogPrint info $ScriptName ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
|
||||||
" from update " . $UpdateID . "!");
|
" from update " . $UpdateID . "!");
|
||||||
:set Done true;
|
:continue;
|
||||||
}
|
}
|
||||||
:if ($Done = false && ($IsMyReply = 1 || ($IsAnyReply = false && \
|
:if (($IsMyReply = 1 || ($IsAnyReply = false && \
|
||||||
$TelegramChatActive = true)) && [ :len $Command ] > 0) do={
|
$TelegramChatActive = true)) && [ :len $Command ] > 0) do={
|
||||||
:if ([ $ValidateSyntax $Command ] = true) do={
|
:if ([ $ValidateSyntax $Command ] = true) do={
|
||||||
:local State "";
|
:local State "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue