forked from eworm-de/routeros-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotate-ntp
32 lines (25 loc) · 896 Bytes
/
rotate-ntp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!rsc by RouterOS
# RouterOS script: rotate-ntp
# Copyright (c) 2013-2021 Christian Hesse <[email protected]>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
# rotate the ntp servers
# https://git.eworm.de/cgit/routeros-scripts/about/doc/rotate-ntp.md
:local 0 "rotate-ntp";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NtpPool;
:global LogPrintExit2;
:local Ntp1;
:local Ntp2;
:if ([ / system ntp client get enabled ] != true) do={
$LogPrintExit2 warning $0 ("NTP client is not enabled!") true;
}
:do {
:set Ntp1 [ :resolve ("0." . $NtpPool) ];
:set Ntp2 [ :resolve ("1." . $NtpPool) ];
} on-error={
$LogPrintExit2 warning $0 ("Resolving NTP server failed.") true;
}
$LogPrintExit2 info $0 ("Updating NTP servers to " . $Ntp1 . " and " . $Ntp2) false;
/ system ntp client set primary-ntp=$Ntp1 secondary-ntp=$Ntp2;