mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-04-16 10:09:37 +00:00
netwatch-dns: early exit with :exit
This commit is contained in:
parent
f5a88be0dc
commit
f8440e3e77
2 changed files with 7 additions and 12 deletions
|
|
@ -4,7 +4,7 @@ Manage DNS and DoH servers from netwatch
|
||||||
[](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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@
|
||||||
# Copyright (c) 2022-2026 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2022-2026 Christian Hesse <mail@eworm.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.19
|
# requires RouterOS, version=7.22
|
||||||
# requires device-mode, fetch
|
# requires device-mode, fetch
|
||||||
#
|
#
|
||||||
# monitor and manage dns/doh with netwatch
|
# monitor and manage dns/doh with netwatch
|
||||||
# https://rsc.eworm.de/doc/netwatch-dns.md
|
# https://rsc.eworm.de/doc/netwatch-dns.md
|
||||||
|
|
||||||
:local ExitOK false;
|
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
||||||
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
||||||
|
|
@ -26,15 +25,13 @@
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
|
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
|
||||||
:if ($SettleTime > 0s) do={
|
:if ($SettleTime > 0s) do={
|
||||||
$LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.");
|
$LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local DnsServers ({});
|
:local DnsServers ({});
|
||||||
|
|
@ -89,8 +86,7 @@
|
||||||
|
|
||||||
:if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={
|
:if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={
|
||||||
$LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent);
|
$LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent);
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:set ($DohServers->[ :len $DohServers ]) $HostInfo;
|
:set ($DohServers->[ :len $DohServers ]) $HostInfo;
|
||||||
|
|
@ -135,8 +131,7 @@
|
||||||
}
|
}
|
||||||
/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"));
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error true;
|
|
||||||
} else={
|
} else={
|
||||||
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
|
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
|
||||||
($DohServer->"doh-url"));
|
($DohServer->"doh-url"));
|
||||||
|
|
@ -144,5 +139,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue