From a6c0c5f0b08a7659f5b15869778bf0f691e92ec4 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 03 2016 06:01:26 +0000 Subject: import chrony-2.1.1-3.el7 --- diff --git a/SOURCES/chrony.helper b/SOURCES/chrony.helper index 78fd944..0831482 100644 --- a/SOURCES/chrony.helper +++ b/SOURCES/chrony.helper @@ -2,9 +2,12 @@ # This script configures running chronyd to use NTP servers obtained from # DHCP and _ntp._udp DNS SRV records. Files with servers from DHCP are managed # externally (e.g. by a dhclient script). Files with servers from DNS SRV -# records are updated here using the dig utility. +# records are updated here using the dig utility. The script can also list +# and set static sources in the chronyd configuration file. chronyc=/usr/bin/chronyc +chrony_conf=/etc/chrony.conf +chrony_service=chronyd.service helper_dir=/var/run/chrony-helper added_servers_file=$helper_dir/added_servers @@ -142,6 +145,57 @@ prepare_helper_dir() { fi } +is_source_line() { + local pattern="^[ \t]*(server|pool|peer|refclock)[ \t]+[^ \t]+" + [[ "$1" =~ $pattern ]] +} + +list_static_sources() { + while read line; do + is_source_line "$line" && echo "$line" || : + done < $chrony_conf +} + +set_static_sources() { + local new_config tmp_conf + + new_config=$( + sources=$( + while read line; do + is_source_line "$line" && echo "$line" + done) + + while read line; do + if ! is_source_line "$line"; then + echo "$line" + continue + fi + + tmp_sources=$( + local removed=0 + + echo "$sources" | while read line2; do + [ "$removed" -ne 0 -o "$line" != "$line2" ] && \ + echo "$line2" || removed=1 + done) + + [ "$sources" == "$tmp_sources" ] && continue + sources=$tmp_sources + echo "$line" + done < $chrony_conf + + echo "$sources" + ) + + tmp_conf=${chrony_conf}.tmp + + cp -a $chrony_conf $tmp_conf && + echo "$new_config" > $tmp_conf && + mv $tmp_conf $chrony_conf || return 1 + + systemctl try-restart $chrony_service +} + print_help() { echo "Usage: $0 COMMAND" echo @@ -151,6 +205,8 @@ print_help() { echo " enable-dnssrv NAME" echo " disable-dnssrv NAME" echo " list-dnssrv" + echo " list-static-sources" + echo " set-static-sources < sources.list" echo " is-running" echo " command CHRONYC-COMMAND" } @@ -172,6 +228,12 @@ case "$1" in list-dnssrv) list_dnssrv_timers ;; + list-static-sources) + list_static_sources + ;; + set-static-sources) + set_static_sources + ;; is-running) is_running ;; diff --git a/SPECS/chrony.spec b/SPECS/chrony.spec index 33f149e..470a9a4 100644 --- a/SPECS/chrony.spec +++ b/SPECS/chrony.spec @@ -4,7 +4,7 @@ Name: chrony Version: 2.1.1 -Release: 1%{?dist} +Release: 3%{?dist} Summary: An NTP client/server Group: System Environment/Daemons @@ -41,7 +41,7 @@ clocks, system real-time clock or manual input as time references. %if 0%{!?vendorzone:1} %{?fedora: %global vendorzone fedora.} -%{?rhel: %global vendorzone centos.} +%{?rhel: %global vendorzone rhel.} %endif %prep @@ -147,8 +147,11 @@ fi %dir %attr(-,chrony,chrony) %{_localstatedir}/log/chrony %changelog -* Thu Nov 19 2015 CentOS Sources - 2.1.1-1.el7.centos -- rebrand vendorzone +* Tue Jun 28 2016 Miroslav Lichvar 2.1.1-3 +- fix chrony-helper to exit with correct status (#1350531) + +* Wed May 25 2016 Miroslav Lichvar 2.1.1-2 +- extend chrony-helper to allow management of static sources (#1331655) * Tue Jun 23 2015 Miroslav Lichvar 2.1.1-1 - update to 2.1.1 (#1117882)