#!/bin/sh
# Adjust the system clock with ntp whenever a network interface is
# brought up, as it might mean we can contact the server.

[ "$IFACE" != "lo" ] || exit 0

test -f /usr/sbin/ntpdate || exit 0

if [ -f /etc/default/ntpdate ]; then
	. /etc/default/ntpdate
	test -n "$NTPSERVERS" || exit 0
else
	NTPSERVERS="ntp.ubuntu.com"
fi

if [ "$VERBOSITY" = 1 ]; then
	echo "Synchronizing clock to $NTPSERVERS..."
	/usr/sbin/ntpdate -b -s $NTPOPTIONS $NTPSERVERS || true
else
	/usr/sbin/ntpdate -b -s $NTPOPTIONS $NTPSERVERS >/dev/null 2>&1 || true
fi
