Files
Paul Eggleton a863b54099 ntp: make servers configurable and default to none configured
People can't blindly use pool.ntp.org, especially if they are building
for a product or something that could be used in a product, so at least
try to get people to do the right thing and not use pool.ntp.org by
default.

The previous network interface up script is now installed as
ntpdate-sync in ${bindir} (and symlinked as the network if-up script).
NTPSERVERS needs to be set in /etc/default/ntpdate.default at runtime,
or a different version of this file with a default value can be provided
in a bbappend. (If you intend to use ntpd you will also want to provide
an ntp.conf with the appropriate server(s) set there as well.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2012-11-27 14:43:58 -05:00

55 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
PATH=/sbin:/bin:/usr/bin
test -x /usr/bin/ntpdate || exit 0
if test -f /etc/default/ntpdate ; then
. /etc/default/ntpdate
fi
if [ "$NTPSERVERS" = "" ] ; then
if [ "$METHOD" = "" -a "$1" != "silent" ] ; then
echo "Please set NTPSERVERS in /etc/default/ntpdate"
exit 1
else
exit 0
fi
fi
# This is a heuristic: The idea is that if a static interface is brought
# up, that is a major event, and we can put in some extra effort to fix
# the system time. Feel free to change this, especially if you regularly
# bring up new network interfaces.
if [ "$METHOD" = static ]; then
OPTS="-b"
fi
if [ "$METHOD" = loopback ]; then
exit 0
fi
(
LOCKFILE=/var/lock/ntpdate
# Avoid running more than one at a time
if [ -x /usr/bin/lockfile-create ]; then
lockfile-create $LOCKFILE
lockfile-touch $LOCKFILE &
LOCKTOUCHPID="$!"
fi
if /usr/bin/ntpdate -s $OPTS $NTPSERVERS 2>/dev/null; then
if [ "$UPDATE_HWCLOCK" = "yes" ]; then
hwclock --systohc || :
fi
fi
if [ -x /usr/bin/lockfile-create ] ; then
kill $LOCKTOUCHPID
lockfile-remove $LOCKFILE
fi
) &