diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-11-22 16:49:35 +0000 |
|---|---|---|
| committer | Joe MacDonald <joe.macdonald@windriver.com> | 2012-11-27 14:43:58 -0500 |
| commit | a863b5409923189c3cfa4d82888f94258da96648 (patch) | |
| tree | f88521b883b9b95c387f970b62f161cbe3f1d702 | |
| parent | 93f71dafeb7a8db2842acb7509e2bc2d01e7bf48 (diff) | |
| download | meta-openembedded-a863b5409923189c3cfa4d82888f94258da96648.tar.gz | |
ntp: make servers configurable and default to none configured
People can't blindly use pool.ntp.org, especially if they are building
for a product or something that could be used in a product, so at least
try to get people to do the right thing and not use pool.ntp.org by
default.
The previous network interface up script is now installed as
ntpdate-sync in ${bindir} (and symlinked as the network if-up script).
NTPSERVERS needs to be set in /etc/default/ntpdate.default at runtime,
or a different version of this file with a default value can be provided
in a bbappend. (If you intend to use ntpd you will also want to provide
an ntp.conf with the appropriate server(s) set there as well.)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
4 files changed, 32 insertions, 13 deletions
diff --git a/meta-networking/recipes-support/ntp/files/ntp.conf b/meta-networking/recipes-support/ntp/files/ntp.conf index bf52440ced..a9cc838450 100644 --- a/meta-networking/recipes-support/ntp/files/ntp.conf +++ b/meta-networking/recipes-support/ntp/files/ntp.conf | |||
| @@ -5,7 +5,7 @@ driftfile /etc/ntp.drift | |||
| 5 | # This obtains a random server which will be close | 5 | # This obtains a random server which will be close |
| 6 | # (in IP terms) to the machine. Add other servers | 6 | # (in IP terms) to the machine. Add other servers |
| 7 | # as required, or change this. | 7 | # as required, or change this. |
| 8 | server pool.ntp.org | 8 | server time.server.example.com |
| 9 | # Using local hardware clock as fallback | 9 | # Using local hardware clock as fallback |
| 10 | # Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself | 10 | # Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself |
| 11 | server 127.127.1.0 | 11 | server 127.127.1.0 |
diff --git a/meta-networking/recipes-support/ntp/files/ntpdate b/meta-networking/recipes-support/ntp/files/ntpdate index 784b029ad5..ab0551c5a5 100755 --- a/meta-networking/recipes-support/ntp/files/ntpdate +++ b/meta-networking/recipes-support/ntp/files/ntpdate | |||
| @@ -6,11 +6,16 @@ test -x /usr/bin/ntpdate || exit 0 | |||
| 6 | 6 | ||
| 7 | if test -f /etc/default/ntpdate ; then | 7 | if test -f /etc/default/ntpdate ; then |
| 8 | . /etc/default/ntpdate | 8 | . /etc/default/ntpdate |
| 9 | else | ||
| 10 | NTPSERVERS="pool.ntp.org" | ||
| 11 | fi | 9 | fi |
| 12 | 10 | ||
| 13 | test -n "$NTPSERVERS" || exit 0 | 11 | if [ "$NTPSERVERS" = "" ] ; then |
| 12 | if [ "$METHOD" = "" -a "$1" != "silent" ] ; then | ||
| 13 | echo "Please set NTPSERVERS in /etc/default/ntpdate" | ||
| 14 | exit 1 | ||
| 15 | else | ||
| 16 | exit 0 | ||
| 17 | fi | ||
| 18 | fi | ||
| 14 | 19 | ||
| 15 | # This is a heuristic: The idea is that if a static interface is brought | 20 | # This is a heuristic: The idea is that if a static interface is brought |
| 16 | # up, that is a major event, and we can put in some extra effort to fix | 21 | # up, that is a major event, and we can put in some extra effort to fix |
diff --git a/meta-networking/recipes-support/ntp/files/ntpdate.default b/meta-networking/recipes-support/ntp/files/ntpdate.default new file mode 100644 index 0000000000..486b6e07d3 --- /dev/null +++ b/meta-networking/recipes-support/ntp/files/ntpdate.default | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | # Configuration script used by ntpdate-sync script | ||
| 2 | |||
| 3 | NTPSERVERS="" | ||
| 4 | |||
| 5 | # Set to "yes" to write time to hardware clock on success | ||
| 6 | UPDATE_HWCLOCK="no" | ||
| 7 | |||
diff --git a/meta-networking/recipes-support/ntp/ntp.inc b/meta-networking/recipes-support/ntp/ntp.inc index a614e3f06a..b3586dc5c9 100644 --- a/meta-networking/recipes-support/ntp/ntp.inc +++ b/meta-networking/recipes-support/ntp/ntp.inc | |||
| @@ -17,6 +17,7 @@ SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.g | |||
| 17 | file://ntpd \ | 17 | file://ntpd \ |
| 18 | file://ntp.conf \ | 18 | file://ntp.conf \ |
| 19 | file://ntpdate \ | 19 | file://ntpdate \ |
| 20 | file://ntpdate.default \ | ||
| 20 | " | 21 | " |
| 21 | 22 | ||
| 22 | inherit autotools update-rc.d | 23 | inherit autotools update-rc.d |
| @@ -37,15 +38,20 @@ do_install_append() { | |||
| 37 | install -d ${D}${sysconfdir}/init.d | 38 | install -d ${D}${sysconfdir}/init.d |
| 38 | install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir} | 39 | install -m 644 ${WORKDIR}/ntp.conf ${D}${sysconfdir} |
| 39 | install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d | 40 | install -m 755 ${WORKDIR}/ntpd ${D}${sysconfdir}/init.d |
| 41 | install -d ${D}${bindir} | ||
| 42 | install -m 755 ${WORKDIR}/ntpdate ${D}${bindir}/ntpdate-sync | ||
| 40 | 43 | ||
| 41 | # Fix hardcoded paths in scripts | 44 | # Fix hardcoded paths in scripts |
| 42 | sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd | 45 | sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 43 | sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd | 46 | sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 44 | sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd | 47 | sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 45 | sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd | 48 | sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/ntpd ${D}${bindir}/ntpdate-sync |
| 46 | 49 | sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${bindir}/ntpdate-sync | |
| 47 | install -d ${D}${sysconfdir}/network/if-up.d | 50 | |
| 48 | install -m 755 ${WORKDIR}/ntpdate ${D}${sysconfdir}/network/if-up.d | 51 | install -d ${D}/${sysconfdir}/default |
| 52 | install -m 644 ${WORKDIR}/ntpdate.default ${D}${sysconfdir}/default/ntpdate | ||
| 53 | install -d ${D}/${sysconfdir}/network/if-up.d | ||
| 54 | ln -s ${bindir}/ntpdate-sync ${D}/${sysconfdir}/network/if-up.d | ||
| 49 | } | 55 | } |
| 50 | 56 | ||
| 51 | PACKAGES += "ntpdate ${PN}-tickadj ${PN}-utils" | 57 | PACKAGES += "ntpdate ${PN}-tickadj ${PN}-utils" |
| @@ -64,9 +70,10 @@ RSUGGESTS_${PN} = "iana-etc" | |||
| 64 | FILES_${PN} = "${bindir}/ntpd ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${sbindir} ${libdir}" | 70 | FILES_${PN} = "${bindir}/ntpd ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd ${sbindir} ${libdir}" |
| 65 | FILES_${PN}-tickadj = "${bindir}/tickadj" | 71 | FILES_${PN}-tickadj = "${bindir}/tickadj" |
| 66 | FILES_${PN}-utils = "${bindir}" | 72 | FILES_${PN}-utils = "${bindir}" |
| 67 | FILES_ntpdate = "${bindir}/ntpdate ${sysconfdir}/network/if-up.d/ntpdate" | 73 | FILES_ntpdate = "${bindir}/ntpdate ${sysconfdir}/network/if-up.d/ntpdate-sync ${bindir}/ntpdate-sync ${sysconfdir}/default/ntpdate" |
| 68 | 74 | ||
| 69 | CONFFILES_${PN} = "${sysconfdir}/ntp.conf" | 75 | CONFFILES_${PN} = "${sysconfdir}/ntp.conf" |
| 76 | CONFFILES_ntpdate = "${sysconfdir}/default/ntpdate" | ||
| 70 | 77 | ||
| 71 | INITSCRIPT_NAME = "ntpd" | 78 | INITSCRIPT_NAME = "ntpd" |
| 72 | # No dependencies, so just go in at the standard level (20) | 79 | # No dependencies, so just go in at the standard level (20) |
| @@ -79,7 +86,7 @@ else | |||
| 79 | if ! grep -q -s ntpdate /var/spool/cron/root; then | 86 | if ! grep -q -s ntpdate /var/spool/cron/root; then |
| 80 | echo "adding crontab" | 87 | echo "adding crontab" |
| 81 | test -d /var/spool/cron || mkdir -p /var/spool/cron | 88 | test -d /var/spool/cron || mkdir -p /var/spool/cron |
| 82 | echo "30 * * * * /usr/bin/ntpdate -b -s -u pool.ntp.org" >> /var/spool/cron/root | 89 | echo "30 * * * * ${bindir}/ntpdate-sync silent" >> /var/spool/cron/root |
| 83 | fi | 90 | fi |
| 84 | fi | 91 | fi |
| 85 | } | 92 | } |
