2021-07-09 10:45:04 +08:00
|
|
|
From: Robert Fairley <rfairley@redhat.com>
|
|
|
|
|
Date: Wed, 17 Jun 2020 10:14:19 -0400
|
|
|
|
|
Subject: [PATCH] examples/nm-dispatcher.dhcp: use sysconfig
|
|
|
|
|
|
|
|
|
|
Use the PEERNTP and NTPSERVERARGS environment variables from
|
|
|
|
|
/etc/sysconfig/network{-scripts}.
|
|
|
|
|
|
|
|
|
|
Co-Authored-By: Christian Glombek <cglombek@redhat.com>
|
|
|
|
|
|
2023-01-31 14:35:17 +08:00
|
|
|
---
|
|
|
|
|
examples/chrony.nm-dispatcher.dhcp | 12 ++++++++++--
|
|
|
|
|
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
|
|
|
2021-07-09 10:45:04 +08:00
|
|
|
diff --git a/examples/chrony.nm-dispatcher.dhcp b/examples/chrony.nm-dispatcher.dhcp
|
2023-01-31 14:35:17 +08:00
|
|
|
index 547ce83..f23756e 100644
|
2021-07-09 10:45:04 +08:00
|
|
|
--- a/examples/chrony.nm-dispatcher.dhcp
|
|
|
|
|
+++ b/examples/chrony.nm-dispatcher.dhcp
|
2023-01-31 14:35:17 +08:00
|
|
|
@@ -10,13 +10,21 @@ action=$2
|
2021-07-09 10:45:04 +08:00
|
|
|
|
|
|
|
|
chronyc=/usr/bin/chronyc
|
2023-01-31 14:35:17 +08:00
|
|
|
server_options=iburst
|
2021-07-09 10:45:04 +08:00
|
|
|
-server_dir=/var/run/chrony-dhcp
|
|
|
|
|
+server_dir=/run/chrony-dhcp
|
|
|
|
|
|
|
|
|
|
dhcp_server_file=$server_dir/$interface.sources
|
2023-01-31 14:35:17 +08:00
|
|
|
dhcp_ntp_servers="$DHCP4_NTP_SERVERS $DHCP6_DHCP6_NTP_SERVERS"
|
2021-07-09 10:45:04 +08:00
|
|
|
|
|
|
|
|
+[ -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
|
|
|
|
|
+
|
2023-01-31 14:35:17 +08:00
|
|
|
for server in $dhcp_ntp_servers; do
|
|
|
|
|
# Check for invalid characters (from the DHCPv6 NTP FQDN suboption)
|
|
|
|
|
len1=$(printf '%s' "$server" | wc -c)
|
|
|
|
|
@@ -25,7 +33,7 @@ add_servers_from_dhcp() {
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- printf 'server %s %s\n' "$server" "$server_options" >> "$dhcp_server_file"
|
|
|
|
|
+ printf 'server %s %s\n' "$server" "${NTPSERVERARGS:-$server_options}" >> "$dhcp_server_file"
|
2021-07-09 10:45:04 +08:00
|
|
|
done
|
|
|
|
|
$chronyc reload sources > /dev/null 2>&1 || :
|
|
|
|
|
}
|
|
|
|
|
--
|
2023-01-31 14:35:17 +08:00
|
|
|
2.23.0
|
2021-07-09 10:45:04 +08:00
|
|
|
|