diff --git a/chrony-service-helper.patch b/chrony-service-helper.patch new file mode 100644 index 0000000..9a34d3e --- /dev/null +++ b/chrony-service-helper.patch @@ -0,0 +1,11 @@ +diff -up chrony-1.31/examples/chronyd.service.service-helper chrony-1.31/examples/chronyd.service +--- chrony-1.31/examples/chronyd.service.service-helper 2014-09-10 17:00:54.000000000 +0200 ++++ chrony-1.31/examples/chronyd.service 2014-07-03 18:09:45.000000000 +0200 +@@ -8,6 +8,7 @@ Type=forking + PIDFile=/var/run/chronyd.pid + EnvironmentFile=-/etc/sysconfig/chronyd + ExecStart=/usr/sbin/chronyd $OPTIONS ++ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers + + [Install] + WantedBy=multi-user.target diff --git a/chrony-wait.service b/chrony-wait.service deleted file mode 100644 index 6513b4f..0000000 --- a/chrony-wait.service +++ /dev/null @@ -1,17 +0,0 @@ -[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 -StandardOutput=null - -[Install] -WantedBy=multi-user.target diff --git a/chrony.conf b/chrony.conf deleted file mode 100644 index 9da0097..0000000 --- a/chrony.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Use public servers from the pool.ntp.org project. -# Please consider joining the pool (http://www.pool.ntp.org/join.html). -server 0.VENDORZONE.pool.ntp.org iburst -server 1.VENDORZONE.pool.ntp.org iburst -server 2.VENDORZONE.pool.ntp.org iburst -server 3.VENDORZONE.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 10 seconds. -makestep 10 3 - -# Allow NTP client access from local network. -#allow 192.168/16 - -# Listen for commands only on localhost. -bindcmdaddress 127.0.0.1 -bindcmdaddress ::1 - -# 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 - -# Generate command key if missing. -generatecommandkey - -# 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 diff --git a/chrony.keys b/chrony.keys deleted file mode 100644 index 6bed03a..0000000 --- a/chrony.keys +++ /dev/null @@ -1 +0,0 @@ -#1 a_key diff --git a/chrony.logrotate b/chrony.logrotate deleted file mode 100644 index e0cd83c..0000000 --- a/chrony.logrotate +++ /dev/null @@ -1,8 +0,0 @@ -/var/log/chrony/*.log { - missingok - nocreate - sharedscripts - postrotate - /usr/bin/chronyc -a cyclelogs > /dev/null 2>&1 || true - endscript -} diff --git a/chrony.nm-dispatcher b/chrony.nm-dispatcher deleted file mode 100644 index ccf409f..0000000 --- a/chrony.nm-dispatcher +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -export LC_ALL=C - -if [ "$2" = "up" ]; then - /sbin/ip route list dev "$1" | grep -q '^default' && - /usr/bin/chronyc -a online > /dev/null 2>&1 -fi - -if [ "$2" = "down" ]; then - /sbin/ip route list | grep -q '^default' || - /usr/bin/chronyc -a offline > /dev/null 2>&1 -fi - -exit 0 diff --git a/chrony.spec b/chrony.spec index a19e241..5f3ab51 100644 --- a/chrony.spec +++ b/chrony.spec @@ -11,18 +11,15 @@ Group: System Environment/Daemons License: GPLv2 URL: http://chrony.tuxfamily.org Source0: http://download.tuxfamily.org/chrony/chrony-%{version}%{?prerelease}.tar.gz -Source1: chrony.conf -Source2: chrony.keys -Source3: chronyd.service -Source4: chrony.helper -Source5: chrony.logrotate -Source7: chrony.nm-dispatcher -Source8: chrony.dhclient -Source9: chrony-wait.service +Source1: chrony.dhclient +Source2: chrony.helper # simulator for test suite from https://github.com/mlichvar/clknetsim.git Source10: clknetsim-%{clknetsim_ver}.tar.gz %{?gitpatch:Patch0: chrony-%{version}%{?prerelease}-%{gitpatch}.patch.gz} +# add NTP servers from DHCP when starting service +Patch1: chrony-service-helper.patch + BuildRequires: libcap-devel libedit-devel nss-devel pps-tools-devel BuildRequires: bison texinfo systemd-units @@ -46,11 +43,26 @@ clocks, system real-time clock or manual input as time references. %prep %setup -q -n %{name}-%{version}%{?prerelease} -a 10 %{?gitpatch:%patch0 -p1} +%patch1 -p1 -b .service-helper %{?gitpatch: echo %{version}-%{gitpatch} > version.txt} -sed -e 's|VENDORZONE\.|%{vendorzone}|' < %{SOURCE1} > chrony.conf -touch -r %{SOURCE1} chrony.conf +# review changes in packaged configuration files and scripts +md5sum -c <<-EOF | (! grep -v 'OK$') + 5cca89b571b0780481fc6f3c518e63bf examples/chrony-wait.service + d77c994ec12c247a5206e724cd70483d examples/chrony.conf.example2 + 2e9fe409a17de5d53a65f9869c4119f5 examples/chrony.logrotate + d7d323d0ea7ccc258710371ea79563d1 examples/chrony.nm-dispatcher + 1a5122f7f40446596777a6c69431c415 examples/chronyd.service +EOF + +# use our vendor zone +sed -e 's|\([0-3]\.\)\(pool.ntp.org\)|\1%{vendorzone}\2|' \ + < examples/chrony.conf.example2 > chrony.conf + +echo '# Keys used by chronyd for command and NTP authentication' > chrony.keys + +touch -r examples/chrony.conf.example2 chrony.conf chrony.keys # regenerate the file from getdate.y rm -f getdate.c @@ -78,15 +90,21 @@ mkdir -p $RPM_BUILD_ROOT%{_libexecdir} mkdir -p $RPM_BUILD_ROOT{%{_unitdir},%{_prefix}/lib/systemd/ntp-units.d} install -m 644 -p chrony.conf $RPM_BUILD_ROOT%{_sysconfdir}/chrony.conf -install -m 640 -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/chrony.keys -install -m 644 -p %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/chronyd.service -install -m 755 -p %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/chrony-helper -install -m 644 -p %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/chrony -install -m 755 -p %{SOURCE7} \ +install -m 640 -p chrony.keys $RPM_BUILD_ROOT%{_sysconfdir}/chrony.keys + +install -m 755 -p examples/chrony.nm-dispatcher \ $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony -install -m 755 -p %{SOURCE8} \ +install -m 755 -p %{SOURCE1} \ $RPM_BUILD_ROOT%{_sysconfdir}/dhcp/dhclient.d/chrony.sh -install -m 644 -p %{SOURCE9} $RPM_BUILD_ROOT%{_unitdir}/chrony-wait.service +install -m 644 -p examples/chrony.logrotate \ + $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/chrony + +install -m 644 -p examples/chronyd.service \ + $RPM_BUILD_ROOT%{_unitdir}/chronyd.service +install -m 644 -p examples/chrony-wait.service \ + $RPM_BUILD_ROOT%{_unitdir}/chrony-wait.service + +install -m 755 -p %{SOURCE2} $RPM_BUILD_ROOT%{_libexecdir}/chrony-helper touch $RPM_BUILD_ROOT%{_localstatedir}/lib/chrony/{drift,rtc} diff --git a/chronyd.service b/chronyd.service deleted file mode 100644 index 3ed34c3..0000000 --- a/chronyd.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=NTP client/server -After=ntpdate.service sntp.service ntpd.service -Conflicts=ntpd.service systemd-timesyncd.service - -[Service] -Type=forking -PIDFile=/var/run/chronyd.pid -EnvironmentFile=-/etc/sysconfig/chronyd -ExecStart=/usr/sbin/chronyd $OPTIONS -ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers - -[Install] -WantedBy=multi-user.target