|
From: <abe...@us...> - 2012-09-27 03:40:02
|
Revision: 5694
http://astlinux.svn.sourceforge.net/astlinux/?rev=5694&view=rev
Author: abelbeck
Date: 2012-09-27 03:39:56 +0000 (Thu, 27 Sep 2012)
Log Message:
-----------
ntp, when ntpd fails to startup when the server is unreachable it will now automatically retry via a background process
Modified Paths:
--------------
branches/1.0/package/ntp/ntpd.init
Modified: branches/1.0/package/ntp/ntpd.init
===================================================================
--- branches/1.0/package/ntp/ntpd.init 2012-09-24 15:33:34 UTC (rev 5693)
+++ branches/1.0/package/ntp/ntpd.init 2012-09-27 03:39:56 UTC (rev 5694)
@@ -50,26 +50,36 @@
}
start () {
+ local NTPAF="" first
+
if [ -f /etc/ntpd.conf ]; then
- local NTPAF
if [ "$IPV6" != "yes" ]; then
NTPAF="-4"
fi
echo "Starting ntpd..."
- if [ -n "$EXTIP" -a -n "$DNS" -o -r /tmp/mydhcpip -o -r /etc/ppp/pppoe.conf ]; then
- local first=`awk '/^server / { print $2; nextfile; }' /etc/ntpd.conf`
+ first="$(awk '/^server / { print $2; nextfile; }' /etc/ntpd.conf)"
+ if [ -n "$first" ]; then
- if nslookup $first >/dev/null; then
- # Set the clock (large change) and exit
- sntp $NTPAF -s -t4 $first
- if [ $? -eq 0 -a -r /dev/rtc ]; then
+ # Set the clock (large change)
+ if sntp $NTPAF -s -t4 $first; then
+ if [ -r /dev/rtc ]; then
hwclock -wu --noadjfile 2>/dev/null
fi
sleep 1
# Maintain the clock (small changes)
ntpd $NTPAF -g -c /etc/ntpd.conf
+ elif ( set -o noclobber; echo "$$" > /var/lock/ntpd-delayed.lock ) 2>/dev/null; then
+ echo "ntpd: server unreachable, will automatically retry in 2 minutes"
+ (
+ sleep 120
+ while [ ! -f /var/run/ntpd.pid ]; do
+ service ntpd start
+ sleep 300
+ done
+ rm -f /var/lock/ntpd-delayed.lock
+ ) >/dev/null 2>&1 &
fi
fi
fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|