[[oe] [PATCH][meta-networking] ntp: get parameters from dhcp] On 15.07.07 (Tue 10:28) rongqing...@windriver.com wrote:
> From: Li Wang <li.w...@windriver.com> > > the script ntp.sh is called by dhcp client, > it can get some parameters from dhcp. > > Signed-off-by: Li Wang <li.w...@windriver.com> > Signed-off-by: Roy Li <rongqing...@windriver.com> > --- > meta-networking/recipes-support/ntp/files/ntp.sh | 59 > ++++++++++++++++++++++ > meta-networking/recipes-support/ntp/ntp_4.2.8p2.bb | 5 ++ > 2 files changed, 64 insertions(+) > create mode 100755 meta-networking/recipes-support/ntp/files/ntp.sh > > diff --git a/meta-networking/recipes-support/ntp/files/ntp.sh > b/meta-networking/recipes-support/ntp/files/ntp.sh > new file mode 100755 > index 0000000..fc109b5 > --- /dev/null > +++ b/meta-networking/recipes-support/ntp/files/ntp.sh > @@ -0,0 +1,59 @@ > +#!/bin/bash As with the other one, I couldn't find any bashisms in this, so if we're going to have our own and not harvest it from the package, maybe change this to /bin/sh. > +# > +# ntp.sh: dhclient-script plugin for NTP settings, > +# place in /etc/dhcp/dhclient.d and 'chmod +x ntp.sh' to enable > +# > +# Copyright (C) 2008 Red Hat, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 2 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see <http://www.gnu.org/licenses/>. > +# > +# Author(s): David Cantrell <dcantr...@redhat.com> > +# Miroslav Lichvar <mlich...@redhat.com> > +# > + > +CONF=/etc/ntp.conf > +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface} > + > +ntp_replace_conf() { > + echo "$1" | diff -q ${CONF} - > /dev/null 2>&1 > + if [ $? -eq 1 ]; then > + echo "$1" > ${CONF} > +# restorecon ${CONF} >/dev/null 2>&1 Please do something about this, too. -J. > + service ntpd restart >/dev/null 2>&1 > + fi > +} > + > +ntp_config() { > + if [ ! "${PEERNTP}" = "no" ] && [ -n "${new_ntp_servers}" ] && > + [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then > + local conf=$(grep -v '^server .* # added by /sbin/dhclient-script$' > < ${CONF}) > + > + conf=$(echo "$conf" > + for s in ${new_ntp_servers}; do > + echo "server ${s} ${NTPSERVERARGS} # added by > /sbin/dhclient-script" > + done) > + > + [ -f ${SAVECONF} ] || touch ${SAVECONF} > + ntp_replace_conf "$conf" > + fi > +} > + > +ntp_restore() { > + if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then > + local conf=$(grep -v '^server .* # added by /sbin/dhclient-script$' > < ${CONF}) > + > + ntp_replace_conf "$conf" > + rm -f ${SAVECONF} > + fi > +} > diff --git a/meta-networking/recipes-support/ntp/ntp_4.2.8p2.bb > b/meta-networking/recipes-support/ntp/ntp_4.2.8p2.bb > index c54da43..b963584 100644 > --- a/meta-networking/recipes-support/ntp/ntp_4.2.8p2.bb > +++ b/meta-networking/recipes-support/ntp/ntp_4.2.8p2.bb > @@ -21,6 +21,7 @@ SRC_URI = > "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.g > file://sntp.service \ > file://sntp \ > file://ntpd.list \ > + file://ntp.sh \ > " > > SRC_URI[md5sum] = "fa37049383316322d060ec9061ac23a9" > @@ -93,6 +94,9 @@ do_install_append() { > > install -d ${D}${systemd_unitdir}/ntp-units.d > install -m 0644 ${WORKDIR}/ntpd.list > ${D}${systemd_unitdir}/ntp-units.d/60-ntpd.list > + > + install -d ${D}/${sysconfdir}/dhcp/dhclient.d > + install -m 755 ${WORKDIR}/ntp.sh ${D}/${sysconfdir}/dhcp/dhclient.d/ > } > > PACKAGES += "ntpdate sntp ${PN}-tickadj ${PN}-utils" > @@ -124,6 +128,7 @@ RSUGGESTS_${PN} = "iana-etc" > FILES_${PN} = "${sbindir}/ntpd ${sysconfdir}/ntp.conf > ${sysconfdir}/init.d/ntpd ${libdir} \ > ${NTP_USER_HOME} \ > ${systemd_unitdir}/ntp-units.d/60-ntpd.list \ > + ${sysconfdir}/dhcp/dhclient.d/ntp.sh \ > " > FILES_${PN}-tickadj = "${sbindir}/tickadj" > FILES_${PN}-utils = "${sbindir} ${datadir}/ntp/lib" > -- > 1.9.1 > -- -Joe MacDonald. :wq
signature.asc
Description: Digital signature
-- _______________________________________________ Openembedded-devel mailing list Openembedded-devel@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-devel