[ntp] use network-online target in ntpdate and sntp services (#1116474)

Miroslav Lichvar mlichvar at fedoraproject.org
Tue Nov 4 16:41:43 UTC 2014


commit 592a26dd25be0c83f2edcddc9600872bac177ee8
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date:   Mon Nov 3 17:12:03 2014 +0100

    use network-online target in ntpdate and sntp services (#1116474)

 ntpdate.service   |    4 ++--
 ntpdate.sysconfig |    3 ---
 ntpdate.wrapper   |   11 ++---------
 sntp.service      |    4 ++--
 4 files changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/ntpdate.service b/ntpdate.service
index 038b293..c470d2c 100644
--- a/ntpdate.service
+++ b/ntpdate.service
@@ -1,8 +1,8 @@
 [Unit]
 Description=Set time via NTP
-After=syslog.target network.target nss-lookup.target
+After=network-online.target
 Before=time-sync.target
-Wants=time-sync.target
+Wants=time-sync.target network-online.target
 
 [Service]
 Type=oneshot
diff --git a/ntpdate.sysconfig b/ntpdate.sysconfig
index 2502779..54676b4 100644
--- a/ntpdate.sysconfig
+++ b/ntpdate.sysconfig
@@ -1,8 +1,5 @@
 # Options for ntpdate
 OPTIONS="-p 2"
 
-# Number of retries before giving up
-RETRIES=2
-
 # Set to 'yes' to sync hw clock after successful ntpdate
 SYNC_HWCLOCK=no
diff --git a/ntpdate.wrapper b/ntpdate.wrapper
index 5baeab0..ed91bec 100755
--- a/ntpdate.wrapper
+++ b/ntpdate.wrapper
@@ -22,15 +22,8 @@ if ! echo "$tickers" | grep -qi '[a-z0-9]'; then
 	exit 6
 fi
 
-[ -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
+/usr/sbin/ntpdate -U ntp -s -b $OPTIONS $tickers &> /dev/null
+RETVAL=$?
 
 [ $RETVAL -eq 0 ] && [ "$SYNC_HWCLOCK" = "yes" ] && /sbin/hwclock --systohc
 exit $RETVAL
diff --git a/sntp.service b/sntp.service
index 70ff227..caba3a0 100644
--- a/sntp.service
+++ b/sntp.service
@@ -1,8 +1,8 @@
 [Unit]
 Description=Set time via SNTP
-After=syslog.target network.target NetworkManager-wait-online.service nss-lookup.target
+After=network-online.target
 Before=time-sync.target
-Wants=time-sync.target
+Wants=time-sync.target network-online.target
 
 [Service]
 Type=oneshot


More information about the scm-commits mailing list