0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-22 15:26:15 +00:00
packages/net/ntpd/files/ntpdate.init
Karl Palsson c00c826789 ntpdate: use uci configured servers instead of static list
If we're going to have a list of ntp servers, we should at least respect
them.  Fallback to the original static list if no configured servers are
found.

Signed-off-by: Karl Palsson <karlp@etactica.com>
2019-07-02 09:25:34 +00:00

16 lines
381 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2008 OpenWrt.org
START=60
DEFAULT_SERVERS="0.openwrt.pool.ntp.org 1.openwrt.pool.ntp.org 2.openwrt.pool.ntp.org"
CFG_SERVERS=$(uci -q get system.ntp.server)
STEP_SERVERS=${CFG_SERVERS:-$DEFAULT_SERVERS}
TIMEOUT="2" # in seconds
start() {
for s in $STEP_SERVERS ; do
/usr/sbin/ntpdate -s -b -u -t "$TIMEOUT" "$s" && break
done
}