patch DHCP NM dispatcher for distribution
Patch the upstream example `nm-dispatcher.dhcp` with Fedora/RHEL-specific behavior including exiting if a dhclient install is detected, and using the /etc/sysconfig paths. Originally part of work for fixing integration between the NetworkManager internal DHCP client and chrony: https://bugzilla.redhat.com/show_bug.cgi?id=1800901
This commit is contained in:
parent
0ecc1e4fe9
commit
9bae83fd80
52
chrony-nm-dispatcher-dhcp.patch
Normal file
52
chrony-nm-dispatcher-dhcp.patch
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
From e0c6457fd42252f88ec60d16582b7b6e6fb04f41 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Robert Fairley <rfairley@redhat.com>
|
||||||
|
Date: Wed, 17 Jun 2020 10:14:19 -0400
|
||||||
|
Subject: [PATCH] examples/nm-dispatcher.dhcp: use sysconfig, detect dhclient
|
||||||
|
|
||||||
|
Use the PEERNTP and NTPSERVERARGS environment variables from
|
||||||
|
/etc/sysconfig/network{-scripts}. Detect a dhclient install to avoid a
|
||||||
|
redundant operation with the 11-dhclient NM dispatcher in the
|
||||||
|
dhcp-client package.
|
||||||
|
---
|
||||||
|
examples/chrony.nm-dispatcher.dhcp | 15 ++++++++++++++-
|
||||||
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/examples/chrony.nm-dispatcher.dhcp b/examples/chrony.nm-dispatcher.dhcp
|
||||||
|
index 6ea4c37..878e72f 100644
|
||||||
|
--- a/examples/chrony.nm-dispatcher.dhcp
|
||||||
|
+++ b/examples/chrony.nm-dispatcher.dhcp
|
||||||
|
@@ -6,6 +6,11 @@
|
||||||
|
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
+# If a dhclient installation is present, avoid a redundant operation
|
||||||
|
+# with dhclient which handles NTP server config through its own
|
||||||
|
+# NetworkManager dispatcher script 11-dhclient.
|
||||||
|
+[ -e /usr/sbin/dhclient ] && exit 0
|
||||||
|
+
|
||||||
|
interface=$1
|
||||||
|
action=$2
|
||||||
|
|
||||||
|
@@ -17,10 +22,18 @@ dhcp_server_file=$server_dir/$interface.sources
|
||||||
|
# DHCP4_NTP_SERVERS is passed from DHCP options by NetworkManager.
|
||||||
|
nm_dhcp_servers=$DHCP4_NTP_SERVERS
|
||||||
|
|
||||||
|
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
|
||||||
|
+[ -f /etc/sysconfig/network-scripts/ifcfg-"${interface}" ] && \
|
||||||
|
+ . /etc/sysconfig/network-scripts/ifcfg-"${interface}"
|
||||||
|
+
|
||||||
|
add_servers_from_dhcp() {
|
||||||
|
rm -f "$dhcp_server_file"
|
||||||
|
+
|
||||||
|
+ # Don't add NTP servers if PEERNTP=no specified; return early.
|
||||||
|
+ [ "$PEERNTP" = "no" ] && return
|
||||||
|
+
|
||||||
|
for server in $nm_dhcp_servers; do
|
||||||
|
- echo "server $server $default_server_options" >> "$dhcp_server_file"
|
||||||
|
+ echo "server $server ${NTPSERVERARGS:-$default_server_options}" >> "$dhcp_server_file"
|
||||||
|
done
|
||||||
|
$chronyc reload sources > /dev/null 2>&1 || :
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.26.2
|
||||||
|
|
10
chrony.spec
10
chrony.spec
@ -21,6 +21,10 @@ Source6: chrony-dnssrv@.timer
|
|||||||
Source10: https://github.com/mlichvar/clknetsim/archive/%{clknetsim_ver}/clknetsim-%{clknetsim_ver}.tar.gz
|
Source10: https://github.com/mlichvar/clknetsim/archive/%{clknetsim_ver}/clknetsim-%{clknetsim_ver}.tar.gz
|
||||||
%{?gitpatch:Patch0: chrony-%{version}%{?prerelease}-%{gitpatch}.patch.gz}
|
%{?gitpatch:Patch0: chrony-%{version}%{?prerelease}-%{gitpatch}.patch.gz}
|
||||||
|
|
||||||
|
# add Fedora/RHEL-specific bits to DHCP dispatcher, including
|
||||||
|
# deferring to dhclient if installled, and using /etc/sysconfig
|
||||||
|
Patch1: chrony-nm-dispatcher-dhcp.patch
|
||||||
|
|
||||||
BuildRequires: libcap-devel libedit-devel nettle-devel pps-tools-devel
|
BuildRequires: libcap-devel libedit-devel nettle-devel pps-tools-devel
|
||||||
%ifarch %{ix86} x86_64 %{arm} aarch64 mipsel mips64el ppc64 ppc64le s390 s390x
|
%ifarch %{ix86} x86_64 %{arm} aarch64 mipsel mips64el ppc64 ppc64le s390 s390x
|
||||||
BuildRequires: libseccomp-devel
|
BuildRequires: libseccomp-devel
|
||||||
@ -52,6 +56,7 @@ service to other computers in the network.
|
|||||||
%{gpgverify} --keyring=%{SOURCE2} --signature=%{SOURCE1} --data=%{SOURCE0}
|
%{gpgverify} --keyring=%{SOURCE2} --signature=%{SOURCE1} --data=%{SOURCE0}
|
||||||
%setup -q -n %{name}-%{version}%{?prerelease} -a 10
|
%setup -q -n %{name}-%{version}%{?prerelease} -a 10
|
||||||
%{?gitpatch:%patch0 -p1}
|
%{?gitpatch:%patch0 -p1}
|
||||||
|
%patch1 -p1 -b .nm-dispatcher-dhcp
|
||||||
|
|
||||||
%{?gitpatch: echo %{version}-%{gitpatch} > version.txt}
|
%{?gitpatch: echo %{version}-%{gitpatch} > version.txt}
|
||||||
|
|
||||||
@ -61,6 +66,7 @@ md5sum -c <<-EOF | (! grep -v 'OK$')
|
|||||||
dcad37a5f1aae2d2ea7b935f279e0eca examples/chrony.conf.example2
|
dcad37a5f1aae2d2ea7b935f279e0eca examples/chrony.conf.example2
|
||||||
96999221eeef476bd49fe97b97503126 examples/chrony.keys.example
|
96999221eeef476bd49fe97b97503126 examples/chrony.keys.example
|
||||||
6a3178c4670de7de393d9365e2793740 examples/chrony.logrotate
|
6a3178c4670de7de393d9365e2793740 examples/chrony.logrotate
|
||||||
|
63aa1412fd9044bde26475e4a9770fbf examples/chrony.nm-dispatcher.dhcp
|
||||||
8f5a98fcb400a482d355b929d04b5518 examples/chrony.nm-dispatcher.onoffline
|
8f5a98fcb400a482d355b929d04b5518 examples/chrony.nm-dispatcher.onoffline
|
||||||
32c34c995c59fd1c3ad1616d063ae4a0 examples/chronyd.service
|
32c34c995c59fd1c3ad1616d063ae4a0 examples/chronyd.service
|
||||||
EOF
|
EOF
|
||||||
@ -128,7 +134,9 @@ install -m 644 -p examples/chrony.logrotate \
|
|||||||
install -m 644 -p examples/chronyd.service \
|
install -m 644 -p examples/chronyd.service \
|
||||||
$RPM_BUILD_ROOT%{_unitdir}/chronyd.service
|
$RPM_BUILD_ROOT%{_unitdir}/chronyd.service
|
||||||
install -m 755 -p examples/chrony.nm-dispatcher.onoffline \
|
install -m 755 -p examples/chrony.nm-dispatcher.onoffline \
|
||||||
$RPM_BUILD_ROOT%{_prefix}/lib/NetworkManager/dispatcher.d/20-chrony
|
$RPM_BUILD_ROOT%{_prefix}/lib/NetworkManager/dispatcher.d/20-chrony-onoffline
|
||||||
|
install -m 755 -p examples/chrony.nm-dispatcher.dhcp \
|
||||||
|
$RPM_BUILD_ROOT%{_prefix}/lib/NetworkManager/dispatcher.d/20-chrony-dhcp
|
||||||
install -m 644 -p examples/chrony-wait.service \
|
install -m 644 -p examples/chrony-wait.service \
|
||||||
$RPM_BUILD_ROOT%{_unitdir}/chrony-wait.service
|
$RPM_BUILD_ROOT%{_unitdir}/chrony-wait.service
|
||||||
install -m 644 -p %{SOURCE5} $RPM_BUILD_ROOT%{_unitdir}/chrony-dnssrv@.service
|
install -m 644 -p %{SOURCE5} $RPM_BUILD_ROOT%{_unitdir}/chrony-dnssrv@.service
|
||||||
|
Loading…
Reference in New Issue
Block a user