From: Oscar Gomez Fuente <oscargomezf@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] ntp: added ntpdate support to the S49ntp script
Date: Tue, 16 Oct 2018 18:44:42 +0200 [thread overview]
Message-ID: <1539708282-23077-1-git-send-email-oscargomezf@gmail.com> (raw)
Signed-off-by: Oscar Gomez Fuente <oscargomezf@gmail.com>
---
package/ntp/S49ntp | 58 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 24 deletions(-)
diff --git a/package/ntp/S49ntp b/package/ntp/S49ntp
index 35e5874..f5c4cb8 100755
--- a/package/ntp/S49ntp
+++ b/package/ntp/S49ntp
@@ -1,34 +1,44 @@
#! /bin/sh
NAME=ntpd
+NTPDATE=/usr/bin/ntpdate
# Read config file if it is present.
-if [ -r /etc/default/$NAME ]
-then
- . /etc/default/$NAME
+if [ -r /etc/default/$NAME ]; then
+. /etc/default/$NAME
fi
-case "$1" in
- start)
- printf "Starting $NAME: "
- start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
- [ $? = 0 ] && echo "OK" || echo "FAIL"
- ;;
- stop)
- printf "Stopping $NAME: "
- start-stop-daemon -K -q -n $NAME
- [ $? = 0 ] && echo "OK" || echo "FAIL"
- ;;
- restart|reload)
- echo "Restarting $NAME: "
- $0 stop
- sleep 1
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|reload}" >&2
- exit 1
- ;;
+case $1 in
+start)
+ printf "Starting $NAME: "
+ if [ -f $NTPDATE ]; then
+ NUM_SERVER=0
+ CURRENT_DATE=$(date | grep "1970")
+ while [ "$NUM_SERVER" != "4" -a "$CURRENT_DATE" != "" ]
+ do
+ $NTPDATE $NUM_SERVER.pool.ntp.org > /dev/null 2>&1
+ CURRENT_DATE=$(date | grep "1970")
+ NUM_SERVER=$(( $NUM_SERVER + 1 ))
+ done
+ fi
+ start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+ ;;
+stop)
+ printf "Stopping $NAME: "
+ start-stop-daemon -K -q -n $NAME
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+ ;;
+restart|reload)
+ echo "Restarting $NAME: "
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|reload}" >&2
+ exit 1
+ ;;
esac
exit 0
--
1.9.1
next reply other threads:[~2018-10-16 16:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 16:44 Oscar Gomez Fuente [this message]
2018-10-16 17:01 ` [Buildroot] [PATCH 1/1] ntp: added ntpdate support to the S49ntp script Matthew Weber
2018-10-17 15:14 ` Oscar Gomez Fuente
2018-10-17 19:49 ` Oscar Gomez Fuente
2018-10-17 20:09 ` Matthew Weber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1539708282-23077-1-git-send-email-oscargomezf@gmail.com \
--to=oscargomezf@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox