mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-19 07:29:33 +00:00
netwatch-dns: early exit with :exit
This commit is contained in:
parent
24cc13ecbb
commit
6acdcb600e
1 changed files with 6 additions and 11 deletions
|
|
@ -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.17
|
# requires RouterOS, version=7.22beta1
|
||||||
# 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 ExitError; $ExitError true [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue