[Lunar-commits] <moonbase> ntp: Added ntpdate support. Timeout is 5 seconds by default.
Moritz Heiber
moe at lunar-linux.org
Tue Jul 15 19:35:57 CEST 2008
commit af90211b22b6e1503e3e8d03c5b4661857fc3f8c
Author: Moritz Heiber <moe at lunar-linux.org>
Date: Tue Jul 15 19:30:31 2008 +0200
ntp: Added ntpdate support. Timeout is 5 seconds by default.
I should all be working fine.
---
net/ntp/init.d/ntpd | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/net/ntp/init.d/ntpd b/net/ntp/init.d/ntpd
index 079c62f..6daca35 100755
--- a/net/ntp/init.d/ntpd
+++ b/net/ntp/init.d/ntpd
@@ -10,6 +10,36 @@
ARGS="-g"
[ -e "/etc/ntp.conf" ] && ARGS="$ARGS -c /etc/ntp.conf"
+start () {
+ # Lets take the hardware clock time first
+ if [ -x /sbin/hwclock ] ; then
+ echo -n "Trying to set initial time ... "
+ if /sbin/hwclock --hctosys ; then
+ echo -e $RESULT_OK
+ else
+ echo -e $RESULT_FAIL
+ fi
+ else
+ echo -n "hwclock is missing! Can't set systen clock! "
+ echo -e $RESULT_WARN
+ fi
+ # Try to get an initial system time. Timeout is very low
+ # to avoid hanging on bad network connections
+ if [ -e /etc/ntp.conf ] ; then
+ SERVER="`grep -m 1 ^server /etc/ntp.conf | awk '{ print $2 }'`"
+ echo -n "Trying to get the current time with ntpdate ... "
+ if ntpdate -t 5 $SERVER &> /dev/null ; then
+ echo -e $RESULT_OK
+ else
+ echo -e $RESULT_FAIL
+ fi
+ else
+ echo -n "Missing ntp.conf! Can't set initial system time with ntpdate! "
+ echo -e $RESULT_WARN
+ fi
+ default_start
+}
+
stop () {
if [ -x /sbin/hwclock ] ; then
# Save the time to hw clock
More information about the Lunar-commits
mailing list