2021-02-01 16:32:54 +00:00
|
|
|
From 1b29e43133d992e735ffbf87d79f008994479036 Mon Sep 17 00:00:00 2001
|
2020-06-26 00:56:53 +00:00
|
|
|
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.
|
2021-02-01 16:32:54 +00:00
|
|
|
|
|
|
|
Co-Authored-By: Christian Glombek <cglombek@redhat.com>
|
2020-06-26 00:56:53 +00:00
|
|
|
---
|
2021-02-01 16:32:54 +00:00
|
|
|
examples/chrony.nm-dispatcher.dhcp | 21 +++++++++++++++++++--
|
|
|
|
1 file changed, 19 insertions(+), 2 deletions(-)
|
2020-06-26 00:56:53 +00:00
|
|
|
|
|
|
|
diff --git a/examples/chrony.nm-dispatcher.dhcp b/examples/chrony.nm-dispatcher.dhcp
|
2021-02-01 16:32:54 +00:00
|
|
|
index 6ea4c37..a6ad35a 100644
|
2020-06-26 00:56:53 +00:00
|
|
|
--- a/examples/chrony.nm-dispatcher.dhcp
|
|
|
|
+++ b/examples/chrony.nm-dispatcher.dhcp
|
2021-02-01 16:32:54 +00:00
|
|
|
@@ -6,21 +6,39 @@
|
2020-06-26 00:56:53 +00:00
|
|
|
|
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
+# If a dhclient installation is present, avoid a redundant operation
|
2021-02-01 16:32:54 +00:00
|
|
|
+# in case dhclient handles NTP server config through its own chrony config script,
|
|
|
|
+# exec'ed by NetworkManager's 11-dhclient dispatcher script.
|
|
|
|
+# In RHCOS, 11-dhclient is excluded and not shipped with base image.
|
|
|
|
+[ -e /usr/sbin/dhclient ] && \
|
|
|
|
+ [ -e /etc/dhcp/dhclient.d/chrony.sh ] && \
|
|
|
|
+ [ -e /etc/NetworkManager/dispatcher.d/11-dhclient -o \
|
|
|
|
+ -e /usr/lib/NetworkManager/dispatcher.d/11-dhclient ] && \
|
|
|
|
+ exit 0
|
2020-06-26 00:56:53 +00:00
|
|
|
+
|
|
|
|
interface=$1
|
|
|
|
action=$2
|
|
|
|
|
2021-02-01 16:32:54 +00:00
|
|
|
chronyc=/usr/bin/chronyc
|
|
|
|
default_server_options=iburst
|
|
|
|
-server_dir=/var/run/chrony-dhcp
|
|
|
|
+server_dir=/run/chrony-dhcp
|
|
|
|
|
|
|
|
dhcp_server_file=$server_dir/$interface.sources
|
2020-06-26 00:56:53 +00:00
|
|
|
# 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 || :
|
|
|
|
}
|
|
|
|
--
|
2021-02-01 16:32:54 +00:00
|
|
|
2.29.2
|
2020-06-26 00:56:53 +00:00
|
|
|
|