From 56b6da71c3d30ae3961f1251afcbb5617dae17a3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 15 May 2020 20:10:24 +0200 Subject: rotate-ntp: log resolve errors --- rotate-ntp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rotate-ntp b/rotate-ntp index e0c1999..22eca07 100644 --- a/rotate-ntp +++ b/rotate-ntp @@ -9,12 +9,19 @@ :global LogPrintExit; -:local Ntp1 [ :resolve ("0." . $NtpPool) ]; -:local Ntp2 [ :resolve ("1." . $NtpPool) ]; +:local Ntp1; +:local Ntp2; :if ([ / system ntp client get enabled ] != true) do={ $LogPrintExit warning "NTP client is not enabled!" true; } +:do { + :set Ntp1 [ :resolve ("0." . $NtpPool) ]; + :set Ntp2 [ :resolve ("1." . $NtpPool) ]; +} on-error={ + $LogPrintExit warning "Resolving NTP server failed." true; +} + $LogPrintExit info ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false; / system ntp client set primary-ntp=$Ntp1 secondary-ntp=$Ntp2; -- cgit v1.2.3-70-g09d2