
--
v7
--
/system ntp client
set enabled=yes
/system ntp client servers
add address=tock.stdtime.gov.tw
add address=watch.stdtime.gov.tw
add address=time.stdtime.gov.tw
add address=clock.stdtime.gov.tw
add address=tick.stdtime.gov.tw
--
--
/system ntp client
set enabled=yes primary-ntp=pool.ntp.org secondary-ntp=pool.ntp.org \
server-dns-names=\
0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org,3.pool.ntp.org
/system scheduler
add comment="Check and set NTP servers" interval=6h name=SetNtpServers \
on-event="# SetNtpServers - Check and set NTP servers from NTP pool\r\
\n# v1.2 Tested and Developed on ROS v5.7\r\
\n\r\
\n#\r\
\n# Change the following line as needed as progName should match script na\
me \r\
\n:local progName \"SetNtpServers\";\r\
\n\r\
\n# Array of NTP pools to use (check www.pool.ntp.org) one or a maximum of\
\_two, a primary & secondary\r\
\n# Modify the following line and array variable based on your locale (def\
ault is north america).\r\
\n:local arrNtpSystems (\"0.pool.ntp.org\", \"1.pool.ntp.org\");\r\
\n# Alternatively the US related pool below can be used. \r\
\n#:local arrNtpSystems (\"0.pool.ntp.org\", \"1.pool.ntp.org\");\r\
\n#\r\
\n# No modification is necessary beyond this line.\r\
\n:put \"\$progName: Running...\";\r\
\n:log info \"\$progName: Running...\";\r\
\n:set arrNtpSystems [ :toarray \$arrNtpSystems ];\r\
\n:if (( [ :len \$arrNtpSystems ] < 1 ) or ( [ :len \$arrNtpSystems ] > 2 \
)) do={ \r\
\n :put \"\$progName: ERROR NTP Systems array (\\\$arrNtpSystems) must \
be either one or two DNS names.\";\r\
\n :log info \"\$progName: ERROR NTP Systems array (\\\$arrNtpSystems) \
must be either one or two DNS names.\";\r\
\n} else={\r\
\n :local arrRosNtpSetting (\"primary-ntp\", \"secondary-ntp\");\r\
\n :local i 0;\r\
\n :foreach strNtpSystem in (\$arrNtpSystems) do={\r\
\n :local ipAddrNtpSystem [ :resolve \$strNtpSystem ];\r\
\n :local strRosNtpSetting [ :pick \$arrRosNtpSetting \$i ];\r\
\n :local strCurrentNtpIp [ /system ntp client get \$strRosNtpSetti\
ng ];\r\
\n :put \"\$progName: NTP server DNS name \$strNtpSystem resolves t\
o \$ipAddrNtpSystem.\";\r\
\n :log info \"\$progName: NTP server DNS name \$strNtpSystem resol\
ves to \$ipAddrNtpSystem.\";\r\
\n :put \"\$progName: Current \$strRosNtpSetting setting is \$strCu\
rrentNtpIp.\";\r\
\n :log info \"\$progName: Current \$strRosNtpSetting setting is \$\
strCurrentNtpIp.\";\r\
\n :if ( [ :toip \$ipAddrNtpSystem ] != [ :toip \$strCurrentNtpIp ]\
\_) do={\r\
\n :put \"\$progName: Changing \$strRosNtpSetting setting to \$\
ipAddrNtpSystem.\";\r\
\n :log info \"\$progName: Changing \$strRosNtpSetting setting \
to \$ipAddrNtpSystem.\";\r\
\n :local strCommand [ :parse \"/system ntp client set \$strRos\
NtpSetting=\\\"\$ipAddrNtpSystem\\\"\" ];\r\
\n \$strCommand;\r\
\n } else={\r\
\n :put \"\$progName: No changes were made for the \$strRosNtpS\
etting NTP setting.\";\r\
\n :log info \"\$progName: No changes were made for the \$strRo\
sNtpSetting NTP setting.\";\r\
\n }\r\
\n :set i (\$i + 1);\r\
\n }\r\
\n}\r\
\n:put \"\$progName: Done.\";\r\
\n:log info \"\$progName: Done.\";" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup
--


