Merge branch 'hheinold/ntp'

Ticket: SYS#1180
This commit is contained in:
Daniel Willmann 2015-05-04 20:04:58 +02:00 committed by Daniel Willmann
commit 933d151e84
4 changed files with 57 additions and 6 deletions

View File

@ -1,19 +1,32 @@
SYSMOCOM := "${@os.path.dirname(bb.data.getVar('FILE', d, True))}" SYSMOCOM := "${@os.path.dirname(bb.data.getVar('FILE', d, True))}"
FILESEXTRAPATHS_prepend := "${SYSMOCOM}/busybox-${SYSMOCOM_ORIG_PV}:${SYSMOCOM}/files:" FILESEXTRAPATHS_prepend := "${SYSMOCOM}/busybox-${SYSMOCOM_ORIG_PV}:${SYSMOCOM}/files:"
PRINC = "24" PRINC = "25"
SRC_URI += "file://busybox-ifplugd.sh \ SRC_URI += "file://busybox-ifplugd.sh \
file://ifplugd.sh" file://ifplugd.sh \
file://udhcpc-ntp.sh \
file://udhcpc-ntp.default \
"
PACKAGES =+ "${PN}-ifplugd" PACKAGES =+ "${PN}-ifplugd ${PN}-udhcpc-ntp"
FILES_${PN}-ifplugd = "${sysconfdir}/ifplugd.sh ${sysconfdir}/init.d/busybox-ifplugd.sh" FILES_${PN}-ifplugd = "${sysconfdir}/ifplugd.sh ${sysconfdir}/init.d/busybox-ifplugd.sh"
FILES_${PN}-udhcpc-ntp = "${sysconfdir}/udhcpc.d/60ntp \
${sysconfdir}/default/udhcpc-ntp \
"
CONFFILES_${PN}-udhcpc-ntp = "${sysconfdir}/default/udhcpc-ntp"
INITSCRIPT_PACKAGES += "${PN}-ifplugd" INITSCRIPT_PACKAGES += "${PN}-ifplugd"
INITSCRIPT_NAME = "busybox-ifplugd.sh" INITSCRIPT_NAME = "busybox-ifplugd.sh"
RDEPENDS_${PN}-udhcpc-ntp = "${PN}-udhcpc"
do_install_append() { do_install_append() {
install -m 0755 ${WORKDIR}/ifplugd.sh ${D}${sysconfdir}/ install -m 0755 ${WORKDIR}/ifplugd.sh ${D}${sysconfdir}/
install -m 0755 ${WORKDIR}/busybox-ifplugd.sh ${D}${sysconfdir}/init.d/ install -m 0755 ${WORKDIR}/busybox-ifplugd.sh ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/udhcpc-ntp.sh ${D}/${sysconfdir}/udhcpc.d/60ntp
install -m 0644 ${WORKDIR}/udhcpc-ntp.default ${D}/${sysconfdir}/default/udhcpc-ntp
} }

View File

@ -0,0 +1,2 @@
USE_NTPSERVER="yes"

View File

@ -0,0 +1,36 @@
#!/bin/sh
NTPDATE_CONF=/etc/default/ntpdate
NTP_CONF=/etc/ntp.conf
[ -r /etc/default/udhcpc-ntp ] && . /etc/default/udhcpc-ntp
if [ "$USE_NTPSERVER" != "yes" ]; then
exit 0
fi
case "$1" in
renew|bound)
if [ -z "$ntpsrv" ]; then
exit 0
fi
printf "ntpserver is %s\n" $ntpsrv
grep -q -s $ntpsrv ${NTPDATE_CONF}
NTPDATE_UPDATE=$?
if [ -w "${NTPDATE_CONF}" -a ${NTPDATE_UPDATE} != 0 ]; then
printf "changing ntpserver for ntpdate\n"
sed -i -e "s/\(NTPSERVERS=\)\(.*\)/\1\"$ntpsrv\"/g" ${NTPDATE_CONF}
/etc/network/if-up.d/ntpdate-sync
fi
grep -q -s $ntpsrv ${NTP_CONF}
NTP_UPDATE=$?
if [ -w "${NTP_CONF}" -a ${NTP_UPDATE} != 0 ]; then
printf "changing ntpserver for ntpd\n"
sed -i -e "1,/^server/s/^\(server\)\(.*\)/\1 $ntpsrv iburst/g" ${NTP_CONF}
systemctl restart ntpd
fi
;;
esac

View File

@ -147,6 +147,9 @@ dhcp-range=wifi-admin,172.16.8.10,172.16.8.254,255.255.255.0,24h
dhcp-range=wifi-onboard,172.16.128.10,172.16.131.254,255.255.252.0,24h dhcp-range=wifi-onboard,172.16.128.10,172.16.131.254,255.255.252.0,24h
dhcp-range=wifi-remote,172.16.132.10,172.16.135.254,255.255.252.0,24h dhcp-range=wifi-remote,172.16.132.10,172.16.135.254,255.255.252.0,24h
# provide the ntp server running on the idu
dhcp-option=option:ntp-server,0.0.0.0
# This is an example of a DHCP range with a network-id, so that # This is an example of a DHCP range with a network-id, so that
# some DHCP options may be set only for this network. # some DHCP options may be set only for this network.
#dhcp-range=red,192.168.0.50,192.168.0.150 #dhcp-range=red,192.168.0.50,192.168.0.150
@ -228,9 +231,6 @@ dhcp-range=wifi-remote,172.16.132.10,172.16.135.254,255.255.252.0,24h
# DNS server - 6 # DNS server - 6
# broadcast address - 28 # broadcast address - 28
# Set the NTP time server addresses to 172.16.1.1
dhcp-option=42,172.16.1.1
# Set the NTP time server address to be the same machine as # Set the NTP time server address to be the same machine as
# is running dnsmasq # is running dnsmasq
#dhcp-option=42,0.0.0.0 #dhcp-option=42,0.0.0.0