diff options
author | Henry Hallam <henry@pericynthion.org> | 2016-06-15 11:17:27 -0700 |
---|---|---|
committer | Joe MacDonald <joe_macdonald@mentor.com> | 2016-06-16 13:28:16 -0400 |
commit | 9cd117a5dc5f26133a855d1cc3bf9604ae178685 (patch) | |
tree | 17e47d742f3c9162bc99539cd2f43e3a0d7a0f93 /meta-networking | |
parent | 5c8efcc9f54d04ac9a7c41176989efb78c4ac54f (diff) | |
download | meta-openembedded-9cd117a5dc5f26133a855d1cc3bf9604ae178685.tar.gz |
chrony: Versatile implementation of NTP
chrony is an alternative to ntpd. In particular it may be useful
for quasi-realtime embedded systems that have a pulse-per-second
time reference available and need to rapidly synchronize to it after
boot, which appears to be unachievable with ntpd.
Signed-off-by: Henry Hallam <henry@pericynthion.org>
Reviewed-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking')
3 files changed, 229 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/chrony/chrony/chrony.conf b/meta-networking/recipes-support/chrony/chrony/chrony.conf new file mode 100644 index 000000000..8d226d31a --- /dev/null +++ b/meta-networking/recipes-support/chrony/chrony/chrony.conf | |||
@@ -0,0 +1,44 @@ | |||
1 | # Use public NTP servers from the pool.ntp.org project. | ||
2 | # Please consider joining the pool project if possible by running your own | ||
3 | # server(s). | ||
4 | # If you are a vendor distributing a product using chrony, you *MUST* | ||
5 | # read and comply with http://www.pool.ntp.org/vendors.html | ||
6 | pool 0.openembedded.pool.ntp.org iburst | ||
7 | |||
8 | # Use a local timeserver in preference to the pool, if it's reachable. | ||
9 | #server 192.168.22.22 iburst minpoll 2 prefer | ||
10 | |||
11 | # Sync to pulse-per-second from an onboard GPS. | ||
12 | #refclock PPS /dev/pps0 poll 0 prefer | ||
13 | # You'll want to enable CONFIG_PPS and CONFIG_PPS_CLIENT_GPIO in your kernel, | ||
14 | # and an entry something like this in your device tree: | ||
15 | # pps { | ||
16 | # compatible = "pps-gpio"; | ||
17 | # gpios = <&ps7_gpio_0 56 0>; | ||
18 | # }; | ||
19 | |||
20 | # In first three updates step the system clock instead of slew | ||
21 | # if the adjustment is larger than 1 second. | ||
22 | makestep 1.0 3 | ||
23 | |||
24 | # Record the rate at which the system clock gains/loses time, | ||
25 | # improving accuracy after reboot | ||
26 | driftfile /var/lib/chrony/drift | ||
27 | |||
28 | # Enable kernel synchronization of the hardware real-time clock (RTC). | ||
29 | rtcsync | ||
30 | |||
31 | # Allow NTP client access from local network. | ||
32 | #allow 192.168/16 | ||
33 | |||
34 | # Serve time even if not synchronized to any NTP server. | ||
35 | #local stratum 10 | ||
36 | |||
37 | # Specify file containing keys for NTP authentication. | ||
38 | #keyfile /etc/chrony.keys | ||
39 | |||
40 | # Specify directory for log files. | ||
41 | logdir /var/log/chrony | ||
42 | |||
43 | # Select which information is logged. | ||
44 | #log measurements statistics tracking | ||
diff --git a/meta-networking/recipes-support/chrony/chrony/chronyd b/meta-networking/recipes-support/chrony/chrony/chronyd new file mode 100644 index 000000000..04f1b681c --- /dev/null +++ b/meta-networking/recipes-support/chrony/chrony/chronyd | |||
@@ -0,0 +1,58 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | # System V init script for chrony | ||
4 | # Adapted from the script already in meta-networking for ntpd | ||
5 | |||
6 | ### BEGIN INIT INFO | ||
7 | # Provides: chrony | ||
8 | # Required-Start: $network $remote_fs $syslog | ||
9 | # Required-Stop: $network $remote_fs $syslog | ||
10 | # Default-Start: 2 3 4 5 | ||
11 | # Default-Stop: | ||
12 | # Short-Description: Start chrony time daemon | ||
13 | ### END INIT INFO | ||
14 | |||
15 | PATH=/sbin:/bin:/usr/bin:/usr/sbin | ||
16 | |||
17 | DAEMON=/usr/sbin/chronyd | ||
18 | PIDFILE=/var/run/chronyd.pid | ||
19 | |||
20 | test -x $DAEMON -a -r /etc/chrony.conf || exit 0 | ||
21 | |||
22 | # Source function library. | ||
23 | . /etc/init.d/functions | ||
24 | |||
25 | # Functions to do individual actions | ||
26 | startdaemon(){ | ||
27 | echo -n "Starting chronyd: " | ||
28 | start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- "$@" | ||
29 | echo "done" | ||
30 | } | ||
31 | stopdaemon(){ | ||
32 | echo -n "Stopping chronyd: " | ||
33 | start-stop-daemon --stop --quiet --oknodo -p $PIDFILE | ||
34 | echo "done" | ||
35 | } | ||
36 | |||
37 | case "$1" in | ||
38 | start) | ||
39 | startdaemon | ||
40 | ;; | ||
41 | stop) | ||
42 | stopdaemon | ||
43 | ;; | ||
44 | force-reload | restart | reload) | ||
45 | stopdaemon | ||
46 | startdaemon | ||
47 | ;; | ||
48 | status) | ||
49 | status /usr/sbin/chronyd; | ||
50 | exit $? | ||
51 | ;; | ||
52 | *) | ||
53 | echo "Usage: chronyd { start | stop | status | restart | reload }" >&2 | ||
54 | exit 1 | ||
55 | ;; | ||
56 | esac | ||
57 | |||
58 | exit 0 | ||
diff --git a/meta-networking/recipes-support/chrony/chrony_2.4.bb b/meta-networking/recipes-support/chrony/chrony_2.4.bb new file mode 100644 index 000000000..aa37caa41 --- /dev/null +++ b/meta-networking/recipes-support/chrony/chrony_2.4.bb | |||
@@ -0,0 +1,127 @@ | |||
1 | SUMMARY = "Versatile implementation of the Network Time Protocol" | ||
2 | DESCRIPTION = "Chrony can synchronize the system clock with NTP \ | ||
3 | servers, reference clocks (e.g. GPS receiver), and manual input using \ | ||
4 | wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) \ | ||
5 | server and peer to provide a time service to other computers in the \ | ||
6 | network. \ | ||
7 | \ | ||
8 | It is designed to perform well in a wide range of conditions, \ | ||
9 | including intermittent network connections, heavily congested \ | ||
10 | networks, changing temperatures (ordinary computer clocks are \ | ||
11 | sensitive to temperature), and systems that do not run continuously, or \ | ||
12 | run on a virtual machine. \ | ||
13 | \ | ||
14 | Typical accuracy between two machines on a LAN is in tens, or a few \ | ||
15 | hundreds, of microseconds; over the Internet, accuracy is typically \ | ||
16 | within a few milliseconds. With a good hardware reference clock \ | ||
17 | sub-microsecond accuracy is possible. \ | ||
18 | \ | ||
19 | Two programs are included in chrony: chronyd is a daemon that can be \ | ||
20 | started at boot time and chronyc is a command-line interface program \ | ||
21 | which can be used to monitor chronyd's performance and to change \ | ||
22 | various operating parameters whilst it is running. \ | ||
23 | \ | ||
24 | This recipe produces two binary packages: 'chrony' which contains chronyd, \ | ||
25 | the configuration file and the init script, and 'chronyc' which contains \ | ||
26 | the client program only." | ||
27 | |||
28 | HOMEPAGE = "http://chrony.tuxfamily.org/" | ||
29 | SECTION = "net" | ||
30 | LICENSE = "GPLv2" | ||
31 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" | ||
32 | |||
33 | SRC_URI = "https://download.tuxfamily.org/chrony/chrony-${PV}.tar.gz \ | ||
34 | file://chrony.conf \ | ||
35 | file://chronyd" | ||
36 | SRC_URI[md5sum] = "d0598aa8a9be8faccef9386f6fc0d5f2" | ||
37 | SRC_URI[sha256sum] = "8d04e7cda2333289c2104b731d39c3c1db94816e43bae35d7ee4e7ae8af6391f" | ||
38 | |||
39 | DEPENDS = "pps-tools" | ||
40 | |||
41 | # Note: Despite being built via './configure; make; make install', | ||
42 | # chrony does not use GNU Autotools. | ||
43 | inherit update-rc.d systemd | ||
44 | |||
45 | # Configuration options: | ||
46 | # - For command line editing support in chronyc, you may specify either | ||
47 | # 'editline' or 'readline' but not both. editline is smaller, but | ||
48 | # many systems already have readline for other purposes so you might want | ||
49 | # to choose that instead. However, beware license incompatibility | ||
50 | # since chrony is GPLv2 and readline versions after 6.0 are GPLv3+. | ||
51 | # You can of course choose neither, but if you're that tight on space | ||
52 | # consider dropping chronyc entirely (you can use it remotely with | ||
53 | # appropriate chrony.conf options). | ||
54 | # - Security-related: | ||
55 | # - 'sechash' is omitted by default because it pulls in nss which is huge. | ||
56 | # - 'privdrop' allows chronyd to run as non-root; would need changes to | ||
57 | # chrony.conf and init script. | ||
58 | # - 'scfilter' enables support for system call filtering, but requires the | ||
59 | # kernel to have CONFIG_SECCOMP enabled. | ||
60 | PACKAGECONFIG ??= "editline scfilter" | ||
61 | PACKAGECONFIG[readline] = "--without-editline,--without-readline,readline" | ||
62 | PACKAGECONFIG[editline] = ",--without-editline,libedit" | ||
63 | PACKAGECONFIG[sechash] = "--without-tomcrypt,--disable-sechash,nss" | ||
64 | PACKAGECONFIG[privdrop] = ",--disable-privdrop,libcap" | ||
65 | PACKAGECONFIG[scfilter] = "--enable-scfilter,--without-seccomp" | ||
66 | |||
67 | # --disable-static isn't supported by chrony's configure script. | ||
68 | DISABLE_STATIC = "" | ||
69 | |||
70 | do_configure() { | ||
71 | ./configure --sysconfdir=${sysconfdir} --bindir=${bindir} --sbindir=${sbindir} \ | ||
72 | --localstatedir=${localstatedir} --datarootdir=${datadir} \ | ||
73 | ${EXTRA_OECONF} | ||
74 | } | ||
75 | |||
76 | do_install() { | ||
77 | # Binaries | ||
78 | install -d ${D}${bindir} | ||
79 | install -m 0755 ${S}/chronyc ${D}${bindir} | ||
80 | install -d ${D}${sbindir} | ||
81 | install -m 0755 ${S}/chronyd ${D}${sbindir} | ||
82 | |||
83 | # Config file | ||
84 | install -d ${D}${sysconfdir} | ||
85 | install -m 644 ${WORKDIR}/chrony.conf ${D}${sysconfdir} | ||
86 | |||
87 | # System V init script | ||
88 | install -d ${D}${sysconfdir}/init.d | ||
89 | install -m 755 ${WORKDIR}/chronyd ${D}${sysconfdir}/init.d | ||
90 | |||
91 | # systemd unit configuration file | ||
92 | install -d ${D}${systemd_unitdir}/system | ||
93 | install -m 0644 ${S}/examples/chronyd.service ${D}${systemd_unitdir}/system/ | ||
94 | |||
95 | # Variable data (for drift and/or rtc file) | ||
96 | install -d ${D}${localstatedir}/lib/chrony | ||
97 | |||
98 | # Log files | ||
99 | install -d ${D}${localstatedir}/log/chrony | ||
100 | |||
101 | # Fix hard-coded paths in config files and init scripts | ||
102 | sed -i -e 's!/var/!${localstatedir}/!g' -e 's!/etc/!${sysconfdir}/!g' \ | ||
103 | -e 's!/usr/sbin/!${sbindir}/!g' -e 's!/usr/bin/!${bindir}/!g' \ | ||
104 | ${D}${sysconfdir}/chrony.conf \ | ||
105 | ${D}${sysconfdir}/init.d/chronyd \ | ||
106 | ${D}${systemd_unitdir}/system/chronyd.service | ||
107 | sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/chronyd | ||
108 | sed -i 's!^EnvironmentFile=.*!EnvironmentFile=-${sysconfdir}/default/chronyd!' ${D}${systemd_unitdir}/system/chronyd.service | ||
109 | } | ||
110 | |||
111 | FILES_${PN} = "${sbindir}/chronyd ${sysconfdir} ${localstatedir}" | ||
112 | CONFFILES_${PN} = "${sysconfdir}/chrony.conf" | ||
113 | INITSCRIPT_NAME = "chronyd" | ||
114 | INITSCRIPT_PARAMS = "defaults" | ||
115 | SYSTEMD_PACKAGES = "${PN}" | ||
116 | SYSTEMD_SERVICE_${PN} = "chronyd.service" | ||
117 | |||
118 | # It's probably a bad idea to run chrony and another time daemon on | ||
119 | # the same system. systemd includes the SNTP client 'timesyncd', which | ||
120 | # will be disabled by chronyd.service, however it will remain on the rootfs | ||
121 | # wasting 150 kB unless you put 'PACKAGECONFIG_remove_pn-systemd = "timesyncd"' | ||
122 | # in a conf file or bbappend somewhere. | ||
123 | RCONFLICTS_${PN} = "ntp ntimed" | ||
124 | |||
125 | # Separate the client program into its own package | ||
126 | PACKAGES =+ "chronyc" | ||
127 | FILES_chronyc = "${bindir}/chronyc" | ||