--- /dev/null
+#!/bin/bash
+
+config=/etc/chrony.conf
+keyfile=/etc/chrony.keys
+chronyc=/usr/bin/chronyc
+dhclient_servers=/var/lib/dhclient/chrony.servers.*
+service_name=chronyd.service
+
+get_key() {
+ awk '/^[ \t]*'$1'\>/ { print $2; exit }' < $keyfile
+}
+
+get_commandkeyid() {
+ awk '/^[ \t]*commandkey\>/ { keyid=$2 } END { print keyid }' < $config
+}
+
+chrony_command() {
+ commandkeyid=$(get_commandkeyid)
+ [ -z "$commandkeyid" ] && return 1
+ commandkey=$(get_key $commandkeyid)
+ [ -z "$commandkey" ] && return 2
+
+ $chronyc <<EOF
+password $commandkey
+$1
+EOF
+}
+
+generate_commandkey() {
+ commandkeyid=$(get_commandkeyid)
+ [ -z "$commandkeyid" ] && return 1
+ commandkey=$(get_key $commandkeyid)
+ [ -z "$commandkey" ] || return 0
+
+ commandkey=$(tr -c -d '[\041-\176]' < /dev/urandom | head -c 8)
+ [ -n "$commandkey" ] && echo "$commandkeyid $commandkey" >> $keyfile
+}
+
+add_dhclient_servers() {
+ command=$(cat $dhclient_servers 2> /dev/null |
+ while read server serverargs; do
+ echo "add server $server $serverargs"
+ done)
+ if [ -n "$command" ]; then
+ chrony_command "$command" &> /dev/null
+ fi
+}
+
+is_running() {
+ systemctl status chronyd.service &> /dev/null
+}
+
+case "$1" in
+ generate-commandkey)
+ generate_commandkey
+ ;;
+ add-dhclient-servers)
+ add_dhclient_servers
+ ;;
+ command)
+ is_running && chrony_command "$2"
+ ;;
+ *)
+ echo $"Usage: $0 {generate-commandkey|add-dhclient-servers|command}"
+ exit 2
+esac
+exit $?
+
--- /dev/null
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+server 0.fedora.pool.ntp.org iburst
+server 1.fedora.pool.ntp.org iburst
+server 2.fedora.pool.ntp.org iburst
+server 3.fedora.pool.ntp.org iburst
+
+# Ignore stratum in source selection.
+stratumweight 0
+
+# Record the rate at which the system clock gains/losses time.
+driftfile /var/lib/chrony/drift
+
+# Enable kernel RTC synchronization.
+rtcsync
+
+# In first three updates step the system clock instead of slew
+# if the adjustment is larger than 100 seconds.
+makestep 100 3
+
+# Allow client access from local network.
+#allow 192.168/16
+
+# Serve time even if not synchronized to any NTP server.
+#local stratum 10
+
+keyfile /etc/chrony.keys
+
+# Specify the key used as password for chronyc.
+commandkey 1
+
+# Disable logging of client accesses.
+noclientlog
+
+# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
+logchange 0.5
+
+logdir /var/log/chrony
+#log measurements statistics tracking
--- /dev/null
+#!/bin/bash
+
+SERVERFILE=$SAVEDIR/chrony.servers.$interface
+
+chrony_config() {
+ rm -f $SERVERFILE
+ if [ "$PEERNTP" != "no" ]; then
+ /usr/libexec/chrony-helper command "$(
+ for server in $new_ntp_servers; do
+ echo "add server $server $NTPSERVERARGS"
+ echo "$server $NTPSERVERARGS" >> $SERVERFILE
+ done)" &> /dev/null
+ fi
+}
+
+chrony_restore() {
+ if [ -f $SERVERFILE ]; then
+ /usr/libexec/chrony-helper command "$(
+ while read server serverargs; do
+ echo "delete $server"
+ done < $SERVERFILE)" &> /dev/null
+ rm -f $SERVERFILE
+ fi
+}
--- /dev/null
+/var/log/chrony/*.log {
+ missingok
+ nocreate
+ sharedscripts
+ postrotate
+ /usr/libexec/chrony-helper command cyclelogs > /dev/null 2>&1 || true
+ endscript
+}
--- /dev/null
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007, 2008 Michael Tremer & Christian Schmidt #
+# #
+# 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 3 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/>. #
+# #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include $(PKGROOT)/Include
+
+PKG_NAME = chrony
+PKG_VER = 1.26
+PKG_REL = 1
+
+PKG_MAINTAINER =
+PKG_GROUPS = System/Daemons
+PKG_URL = http://chrony.tuxfamily.org
+PKG_LICENSE = GPLv2
+PKG_SUMMARY = An NTP client/server.
+
+PKG_BUILD_DEPS+= bison libcap-devel readline-devel texinfo
+
+define PKG_DESCRIPTION
+ A client/server for the Network Time Protocol, this program keeps your
+ computer's clock accurate. It was specially designed to support
+ systems with intermittent internet connections, but it also works well
+ in permanently connected environments. It can use also hardware reference
+ clocks, system real-time clock or manual input as time references.
+endef
+
+PKG_TARBALL = $(THISAPP).tar.gz
+
+PKG_PACKAGES += $(PKG_NAME)-devel
+
+CONFIGURE_OPTIONS += \
+ --with-sendmail=/usr/sbin/sendmail
+
+STAGE_BUILD_TARGETS += getdate all docs
+STAGE_INSTALL_TARGETS += install-docs
+
+define STAGE_INSTALL_CMDS
+ -mkdir -pv $(BUILDROOT)/var/{lib,log}/chrony
+ touch $(BUILDROOT)/var/lib/chrony/{drift,rtc}
+
+ -mkdir -pv $(BUILDROOT)/etc
+ install -m 644 -p $(DIR_SOURCE)/chrony.conf $(BUILDROOT)/etc/chrony.conf
+ install -m 640 -p $(DIR_SOURCE)/chrony.keys $(BUILDROOT)/etc/chrony.keys
+
+ -mkdir -pv $(BUILDROOT)/etc/dhcp/dhclient.d
+ install -m 755 -p $(DIR_SOURCE)/chrony.dhclient \
+ $(BUILDROOT)/etc/dhcp/dhclient.d/chrony.sh
+
+ -mkdir -pv $(BUILDROOT)/etc/logrotate.d
+ install -m 644 -p $(DIR_SOURCE)/chrony.logrotate \
+ $(BUILDROOT)/etc/logrotate.d/chrony
+
+ -mkdir -pv $(BUILDROOT)/usr/lib/chrony
+ install -m 755 -p $(DIR_SOURCE)/chrony-helper $(BUILDROOT)/usr/lib/chrony-helper
+endef
--- /dev/null
+[Unit]
+Description=Wait for chrony to synchronize system clock
+After=chronyd.service
+Requires=chronyd.service
+Before=time-sync.target
+Wants=time-sync.target
+
+[Service]
+Type=oneshot
+# Wait up to ~10 minutes for chronyd to synchronize and the remaining
+# clock correction to be less than 0.1 seconds
+ExecStart=/usr/bin/chronyc waitsync 60 0.1
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+[Unit]
+Description=NTP client/server
+After=syslog.target ntpdate.service
+Conflicts=ntpd.service
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/chronyd
+ExecStartPre=/usr/libexec/chrony-helper generate-commandkey
+ExecStart=/usr/sbin/chronyd -n -u chrony $OPTIONS
+ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers
+
+[Install]
+WantedBy=multi-user.target