meta-digi-del: add 'busybox-ntpd' package
Use busybox' ntpd applet as basic ntp client. https://jira.digi.com/browse/DEL-144 #resolve Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
9292ff3e4d
commit
de86402042
|
|
@ -0,0 +1,65 @@
|
||||||
|
From: Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
Date: Tue, 25 Sep 2012 14:06:13 +0200
|
||||||
|
Subject: [PATCH] ntpd: indefinitely try to resolve peer addresses
|
||||||
|
|
||||||
|
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
(cherry picked from commit c5daea7ba5200158fae2e68714725c6bf7ee6dbb)
|
||||||
|
|
||||||
|
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
networking/ntpd.c
|
||||||
|
---
|
||||||
|
networking/ntpd.c | 25 +++++++++++++++++++++++--
|
||||||
|
1 file changed, 23 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/networking/ntpd.c b/networking/ntpd.c
|
||||||
|
index 34b649f..49fb58b 100644
|
||||||
|
--- a/networking/ntpd.c
|
||||||
|
+++ b/networking/ntpd.c
|
||||||
|
@@ -221,6 +221,7 @@ typedef struct {
|
||||||
|
typedef struct {
|
||||||
|
len_and_sockaddr *p_lsa;
|
||||||
|
char *p_dotted;
|
||||||
|
+ char *p_hostname;
|
||||||
|
/* when to send new query (if p_fd == -1)
|
||||||
|
* or when receive times out (if p_fd >= 0): */
|
||||||
|
int p_fd;
|
||||||
|
@@ -708,8 +709,9 @@ add_peers(char *s)
|
||||||
|
peer_t *p;
|
||||||
|
|
||||||
|
p = xzalloc(sizeof(*p));
|
||||||
|
- p->p_lsa = xhost2sockaddr(s, 123);
|
||||||
|
- p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
|
||||||
|
+ p->p_hostname = s;
|
||||||
|
+ p->p_lsa = NULL;
|
||||||
|
+ p->p_dotted = NULL;
|
||||||
|
p->p_fd = -1;
|
||||||
|
p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
|
||||||
|
p->next_action_time = G.cur_time; /* = set_next(p, 0); */
|
||||||
|
@@ -758,6 +760,25 @@ send_query_to_peer(peer_t *p)
|
||||||
|
*
|
||||||
|
* Uncomment this and use strace to see it in action:
|
||||||
|
*/
|
||||||
|
+
|
||||||
|
+ /* See if the peer hostname already resolved yet, if not, retry to resolv and return on failure */
|
||||||
|
+ if (!p->p_lsa)
|
||||||
|
+ {
|
||||||
|
+ p->p_lsa = host2sockaddr(p->p_hostname, 123);
|
||||||
|
+
|
||||||
|
+ if (p->p_lsa)
|
||||||
|
+ {
|
||||||
|
+ p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
|
||||||
|
+ VERB1 bb_error_msg("resolved peer %s to %s", p->p_hostname, p->p_dotted);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ set_next(p, RETRY_INTERVAL);
|
||||||
|
+ VERB1 bb_error_msg("could not resolve peer %s, skipping", p->p_hostname);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
#define PROBE_LOCAL_ADDR /* { len_and_sockaddr lsa; lsa.len = LSA_SIZEOF_SA; getsockname(p->query.fd, &lsa.u.sa, &lsa.len); } */
|
||||||
|
|
||||||
|
if (p->p_fd == -1) {
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# busybox-ntpd
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 by Digi International Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License version 2 as published by
|
||||||
|
# the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# !Description: Busybox NTP bootscript
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DAEMON="/usr/sbin/ntpd"
|
||||||
|
NAME="ntpd"
|
||||||
|
DESC="Busybox NTP client/server"
|
||||||
|
ARGS="-n -p pool.ntp.org"
|
||||||
|
|
||||||
|
[ -x "${DAEMON}" ] || exit 0
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Starting $DESC: "
|
||||||
|
start-stop-daemon -S -b -n $NAME -a $DAEMON -- $ARGS
|
||||||
|
echo "done"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo -n "Stopping $DESC: "
|
||||||
|
start-stop-daemon -K -n $NAME
|
||||||
|
echo "done"
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
echo -n "Restarting $DESC: "
|
||||||
|
$0 stop
|
||||||
|
$0 start
|
||||||
|
echo "done"
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
echo -n "Reloading $DESC: "
|
||||||
|
killall -HUP $(basename ${DAEMON})
|
||||||
|
echo "done"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|reload}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -6,11 +6,13 @@ DEPENDS += "libdigi"
|
||||||
SRC_URI += "file://0001-del-baudrates.patch \
|
SRC_URI += "file://0001-del-baudrates.patch \
|
||||||
file://0002-del-mdev_regulatory.patch \
|
file://0002-del-mdev_regulatory.patch \
|
||||||
file://0003-del-flash_eraseall.patch \
|
file://0003-del-flash_eraseall.patch \
|
||||||
|
file://0004-ntpd-indefinitely-try-to-resolve-peer-addresses.patch \
|
||||||
file://adc \
|
file://adc \
|
||||||
file://mmc \
|
file://mmc \
|
||||||
file://sd \
|
file://sd \
|
||||||
file://ts \
|
file://ts \
|
||||||
file://suspend \
|
file://suspend \
|
||||||
|
file://busybox-ntpd \
|
||||||
"
|
"
|
||||||
|
|
||||||
# Add device handlers to 'mdev' package
|
# Add device handlers to 'mdev' package
|
||||||
|
|
@ -19,6 +21,12 @@ FILES_${PN}-mdev += "${base_libdir}/mdev/adc ${base_libdir}/mdev/mmc ${base_libd
|
||||||
# hwclock bootscript init parameters
|
# hwclock bootscript init parameters
|
||||||
INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
|
INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
|
||||||
|
|
||||||
|
# NTPD package
|
||||||
|
PACKAGES =+ "${PN}-ntpd"
|
||||||
|
FILES_${PN}-ntpd = "${sysconfdir}/init.d/busybox-ntpd"
|
||||||
|
INITSCRIPT_PACKAGES =+ "${PN}-ntpd"
|
||||||
|
INITSCRIPT_NAME_${PN}-ntpd = "busybox-ntpd"
|
||||||
|
|
||||||
do_install_append() {
|
do_install_append() {
|
||||||
if grep "CONFIG_MDEV=y" ${WORKDIR}/defconfig; then
|
if grep "CONFIG_MDEV=y" ${WORKDIR}/defconfig; then
|
||||||
if grep "CONFIG_FEATURE_MDEV_CONF=y" ${WORKDIR}/defconfig; then
|
if grep "CONFIG_FEATURE_MDEV_CONF=y" ${WORKDIR}/defconfig; then
|
||||||
|
|
@ -33,6 +41,9 @@ do_install_append() {
|
||||||
ln -s ../lib/mdev/sd ${D}${base_bindir}/usbumount
|
ln -s ../lib/mdev/sd ${D}${base_bindir}/usbumount
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if grep "CONFIG_NTPD=y" ${WORKDIR}/defconfig; then
|
||||||
|
install -m 0755 ${WORKDIR}/busybox-ntpd ${D}${sysconfdir}/init.d/
|
||||||
|
fi
|
||||||
# Install 'suspend' script
|
# Install 'suspend' script
|
||||||
install -m 0755 ${WORKDIR}/suspend ${D}${base_bindir}
|
install -m 0755 ${WORKDIR}/suspend ${D}${base_bindir}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ RDEPENDS_${PN} = "\
|
||||||
base-files \
|
base-files \
|
||||||
base-passwd \
|
base-passwd \
|
||||||
busybox \
|
busybox \
|
||||||
|
busybox-ntpd \
|
||||||
${VIRTUAL-RUNTIME_passwd_manager} \
|
${VIRTUAL-RUNTIME_passwd_manager} \
|
||||||
${VIRTUAL-RUNTIME_initscripts} \
|
${VIRTUAL-RUNTIME_initscripts} \
|
||||||
${@base_contains("MACHINE_FEATURES", "rtc", "busybox-hwclock", "", d)} \
|
${@base_contains("MACHINE_FEATURES", "rtc", "busybox-hwclock", "", d)} \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue