mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-03-04 04:59:35 +00:00
Compare commits
9 commits
8dcdc4b086
...
66764ed0b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66764ed0b2 | ||
|
|
e694477fdc | ||
|
|
875ac9f7c3 | ||
|
|
49d3a448c6 | ||
|
|
9b2099e402 | ||
|
|
679583bbbf | ||
|
|
df8d0370c5 | ||
|
|
cc56680206 | ||
|
|
6fd28bf8f7 |
9 changed files with 41 additions and 55 deletions
|
|
@ -4,7 +4,7 @@ Initial commands
|
|||
[](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)
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ Run the complete base installation:
|
|||
:if (!((($CertSettings->"builtin-trust-anchors") = "trusted" || \
|
||||
($CertSettings->"builtin-trust-store") ~ "fetch" || \
|
||||
($CertSettings->"builtin-trust-store") = "all") && \
|
||||
[[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CertCommonName . "\" ] ]") ]] > 0)) do={
|
||||
[ :len [ /certificate/builtin/find where common-name=$CertCommonName ] ] > 0)) do={
|
||||
:put "Importing certificate...";
|
||||
/tool/fetch ($BaseUrl . "certs/" . $CertFileName) dst-path=$CertFileName as-value;
|
||||
:delay 1s;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.17
|
||||
# requires RouterOS, version=7.19
|
||||
# requires device-mode, fetch
|
||||
#
|
||||
# check for certificate validity
|
||||
|
|
@ -117,10 +117,7 @@
|
|||
:local Return "";
|
||||
:for I from=0 to=5 do={
|
||||
:set Return ($Return . [ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN");
|
||||
:local CertSettings [ /certificate/settings/get ];
|
||||
:if (([ :len ($CertSettings->"builtin-trust-anchors") ] > 0 || \
|
||||
[ :len ($CertSettings->"builtin-trust-store") ] > 0) && \
|
||||
[[ :parse (":return [ :len [ /certificate/builtin/find where skid=\"" . ($CertVal->"akid") . "\" ] ]") ]] > 0) do={
|
||||
:if ([ :len [ /certificate/builtin/find where skid=($CertVal->"akid") ] ] > 0) do={
|
||||
:return $Return;
|
||||
}
|
||||
:do {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Renew certificates and notify on expiration
|
|||
[](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)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Forward log messages via notification
|
|||
[](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)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import that key:
|
|||
$SSHKeysImport "ssh-rsa AAAAB3Nza...QYZk8= user" admin;
|
||||
|
||||
The third part of the key (`user` in this example) is inherited as
|
||||
`key-owner` in RouterOS (or `info` starting with RouterOS 7.21beta2). Also
|
||||
`info` in RouterOS (or `key-owner` with RouterOS 7.20.x and before). Also
|
||||
the `MD5` fingerprint is recorded, this helps to audit and verify the
|
||||
available keys.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# Michael Gisbers <michael@gisbers.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.17
|
||||
# requires RouterOS, version=7.19
|
||||
# requires device-mode, fetch, scheduler
|
||||
#
|
||||
# global functions
|
||||
|
|
@ -47,7 +47,6 @@
|
|||
:global GetRandom20CharHex;
|
||||
:global GetRandomNumber;
|
||||
:global Grep;
|
||||
:global HexToNum;
|
||||
:global HumanReadableNum;
|
||||
:global IfThenElse;
|
||||
:global IsDefaultRouteReachable;
|
||||
|
|
@ -131,7 +130,7 @@
|
|||
:if ((($CertSettings->"builtin-trust-anchors") = "trusted" || \
|
||||
($CertSettings->"builtin-trust-store") ~ $UseFor || \
|
||||
($CertSettings->"builtin-trust-store") = "all") && \
|
||||
[[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CommonName . "\" ] ]") ]] > 0) do={
|
||||
[ :len [ /certificate/builtin/find where common-name=$CommonName ] ] > 0) do={
|
||||
:return true;
|
||||
}
|
||||
|
||||
|
|
@ -717,19 +716,6 @@
|
|||
:return [];
|
||||
}
|
||||
|
||||
# convert from hex (string) to num
|
||||
:set HexToNum do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
||||
:global HexToNum;
|
||||
|
||||
:if ([ :pick $Input 0 ] = "*") do={
|
||||
:return [ $HexToNum [ :pick $Input 1 [ :len $Input ] ] ];
|
||||
}
|
||||
|
||||
:return [ :tonum ("0x" . $Input) ];
|
||||
}
|
||||
|
||||
# return human readable number
|
||||
:set HumanReadableNum do={
|
||||
:local Input [ :tonum $1 ];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (c) 2020-2026 Christian Hesse <mail@eworm.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.17
|
||||
# requires RouterOS, version=7.22beta1
|
||||
#
|
||||
# forward log messages via notification
|
||||
# https://rsc.eworm.de/doc/log-forward.md
|
||||
|
|
@ -24,7 +24,6 @@
|
|||
:global LogForwardRateLimit;
|
||||
|
||||
:global EitherOr;
|
||||
:global HexToNum;
|
||||
:global IfThenElse;
|
||||
:global LogForwardFilterLogForwarding;
|
||||
:global LogPrint;
|
||||
|
|
@ -38,6 +37,10 @@
|
|||
:error false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $LogForwardLast ] = "nothing") do={
|
||||
:set LogForwardLast false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
|
||||
:set LogForwardRateLimit 0;
|
||||
}
|
||||
|
|
@ -51,7 +54,6 @@
|
|||
|
||||
:local Count 0;
|
||||
:local Duplicates false;
|
||||
:local Last [ $IfThenElse ([ :len $LogForwardLast ] > 0) [ $HexToNum $LogForwardLast ] -1 ];
|
||||
:local Messages "";
|
||||
:local Warning false;
|
||||
:local MessageVal;
|
||||
|
|
@ -62,33 +64,34 @@
|
|||
:set LogForwardInclude [ $EitherOr $LogForwardInclude [] ];
|
||||
:set LogForwardIncludeMessage [ $EitherOr $LogForwardIncludeMessage [] ];
|
||||
|
||||
:local LogAll [ /log/find ];
|
||||
:local Max ($LogAll->([ :len $LogAll ] - 1));
|
||||
:local LogForwardFilterLogForwardingCached [ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ];
|
||||
:foreach Message in=[ /log/find where (!(message="") and \
|
||||
!(message~$LogForwardFilterLogForwardingCached) and \
|
||||
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
|
||||
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
|
||||
|
||||
:foreach Message in=[ /log/find where .id>$LogForwardLast and .id<=$Max and \
|
||||
((!(message="") and !(message~$LogForwardFilterLogForwardingCached) and \
|
||||
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
|
||||
topics~$LogForwardInclude or message~$LogForwardIncludeMessage) ] do={
|
||||
:set MessageVal [ /log/get $Message ];
|
||||
:local Bullet "information";
|
||||
|
||||
:if ($Last < [ $HexToNum ($MessageVal->".id") ]) do={
|
||||
:local DupCount ($MessageDups->($MessageVal->"message"));
|
||||
:if ($MessageVal->"topics" ~ "(warning)") do={
|
||||
:set Warning true;
|
||||
:set Bullet "large-orange-circle";
|
||||
}
|
||||
:if ($MessageVal->"topics" ~ "(emergency|alert|critical|error)") do={
|
||||
:set Warning true;
|
||||
:set Bullet "large-red-circle";
|
||||
}
|
||||
:if ($DupCount < 3) do={
|
||||
:set Messages ($Messages . "\n" . [ $SymbolForNotification $Bullet ] . \
|
||||
$MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message");
|
||||
} else={
|
||||
:set Duplicates true;
|
||||
}
|
||||
:set ($MessageDups->($MessageVal->"message")) ($DupCount + 1);
|
||||
:set Count ($Count + 1);
|
||||
:local DupCount ($MessageDups->($MessageVal->"message"));
|
||||
:if ($MessageVal->"topics" ~ "(warning)") do={
|
||||
:set Warning true;
|
||||
:set Bullet "large-orange-circle";
|
||||
}
|
||||
:if ($MessageVal->"topics" ~ "(emergency|alert|critical|error)") do={
|
||||
:set Warning true;
|
||||
:set Bullet "large-red-circle";
|
||||
}
|
||||
:if ($DupCount < 3) do={
|
||||
:set Messages ($Messages . "\n" . [ $SymbolForNotification $Bullet ] . \
|
||||
$MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message");
|
||||
} else={
|
||||
:set Duplicates true;
|
||||
}
|
||||
:set ($MessageDups->($MessageVal->"message")) ($DupCount + 1);
|
||||
:set Count ($Count + 1);
|
||||
}
|
||||
|
||||
:if ($Count > 0) do={
|
||||
|
|
@ -106,8 +109,7 @@
|
|||
:set LogForwardRateLimit [ $MAX 0 ($LogForwardRateLimit - 1) ];
|
||||
}
|
||||
|
||||
:local LogAll [ /log/find ];
|
||||
:set LogForwardLast ($LogAll->([ :len $LogAll ] - 1) );
|
||||
:set LogForwardLast $Max;
|
||||
} do={
|
||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@
|
|||
|
||||
:foreach DohServer in=$DohServers do={
|
||||
:if ([ :len ($DohServer->"doh-cert") ] > 0) do={
|
||||
:if ([ $CertificateAvailable ($DohServer->"doh-cert") "dns" ] = false) do={
|
||||
:if ([ $CertificateAvailable ($DohServer->"doh-cert") "fetch" ] = false || \
|
||||
[ $CertificateAvailable ($DohServer->"doh-cert") "dns" ] = false) do={
|
||||
$LogPrint warning $ScriptName ("Downloading certificate failed, trying without.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue