[ntp] retry few times in ntpdate init script before giving up (#445229)
Miroslav Lichvar
mlichvar at fedoraproject.org
Mon Aug 23 13:12:17 UTC 2010
commit 42f496417dc12ecd3cad5a64ac683b2da4aa7a43
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date: Mon Aug 23 14:51:26 2010 +0200
retry few times in ntpdate init script before giving up (#445229)
ntpdate.init | 13 +++++++++++--
ntpdate.sysconfig | 5 ++++-
2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/ntpdate.init b/ntpdate.init
index d12a8cc..a90c254 100755
--- a/ntpdate.init
+++ b/ntpdate.init
@@ -44,8 +44,17 @@ start() {
fi
echo -n $"$prog: Synchronizing with time server: "
- /usr/sbin/ntpdate $OPTIONS $tickers &> /dev/null
- RETVAL=$?
+
+ [ -z "$RETRIES" ] && RETRIES=2
+ retry=0
+ while true; do
+ /usr/sbin/ntpdate -U ntp -s -b $OPTIONS $tickers &> /dev/null
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] || [ $retry -ge "$RETRIES" ] && break
+ sleep $[10 * (1 << $retry)]
+ retry=$[$retry + 1]
+ done
+
[ $RETVAL -eq 0 ] && success || failure
echo
if [ $RETVAL -eq 0 ]; then
diff --git a/ntpdate.sysconfig b/ntpdate.sysconfig
index 667093a..35bd732 100644
--- a/ntpdate.sysconfig
+++ b/ntpdate.sysconfig
@@ -1,5 +1,8 @@
# Options for ntpdate
-OPTIONS="-U ntp -s -b"
+OPTIONS="-q 2"
+
+# Number of retries before giving up
+RETRIES=2
# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=no
More information about the scm-commits
mailing list