mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-20 16:09:32 +00:00
netwatch-dns: early exit with :exit
This commit is contained in:
parent
394c204a4d
commit
bb40c7a33d
1 changed files with 5 additions and 10 deletions
|
|
@ -9,7 +9,6 @@
|
|||
# monitor and manage dns/doh with netwatch
|
||||
# https://rsc.eworm.de/doc/netwatch-dns.md
|
||||
|
||||
:local ExitOK false;
|
||||
:onerror Err {
|
||||
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
||||
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
||||
|
|
@ -26,15 +25,13 @@
|
|||
:global ScriptLock;
|
||||
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:set ExitOK true;
|
||||
:error false;
|
||||
:exit;
|
||||
}
|
||||
|
||||
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
|
||||
:if ($SettleTime > 0s) do={
|
||||
$LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.");
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
:exit;
|
||||
}
|
||||
|
||||
:local DnsServers ({});
|
||||
|
|
@ -89,8 +86,7 @@
|
|||
|
||||
:if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={
|
||||
$LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent);
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
:exit;
|
||||
}
|
||||
|
||||
:set ($DohServers->[ :len $DohServers ]) $HostInfo;
|
||||
|
|
@ -135,8 +131,7 @@
|
|||
}
|
||||
/ip/dns/cache/flush;
|
||||
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
:exit;
|
||||
} else={
|
||||
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
|
||||
($DohServer->"doh-url"));
|
||||
|
|
@ -144,5 +139,5 @@
|
|||
}
|
||||
}
|
||||
} do={
|
||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
||||
:global ExitError; $ExitError false [ :jobname ] $Err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue