From 0f743e093baeef1dfb34faecb2df03a60cb7122f Mon Sep 17 00:00:00 2001 From: Elston LEWIS Date: Thu, 24 Oct 2024 14:09:37 +0200 Subject: [PATCH] Updated chrony ntp sync script --- files/chrony-specific/10-dhcp-chrony.sh | 10 ++++++++++ scripts/linux/ntp.sh | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 files/chrony-specific/10-dhcp-chrony.sh diff --git a/files/chrony-specific/10-dhcp-chrony.sh b/files/chrony-specific/10-dhcp-chrony.sh new file mode 100644 index 0000000..38f794b --- /dev/null +++ b/files/chrony-specific/10-dhcp-chrony.sh @@ -0,0 +1,10 @@ +#!/bin/sh +if [ "$2" = "up" ]; then + if [ -n "$DHCP4_NTP_SERVERS" ]; then + chronyc delete sources + for server in $DHCP4_NTP_SERVERS; do + chronyc add server $server iburst + done + systemctl restart chronyd + fi +fi \ No newline at end of file diff --git a/scripts/linux/ntp.sh b/scripts/linux/ntp.sh index 93d628e..9f35f27 100644 --- a/scripts/linux/ntp.sh +++ b/scripts/linux/ntp.sh @@ -6,7 +6,9 @@ if [[ "$1" == "debian12" ]]; then chroot /mnt/ apt install chrony -y fi -# make executable chronyd script fix OMI-239 +# chronyd dhcp sync fix OMI-239 if [[ "$1" == "debian12" ]]; then chmod +x /mnt/etc/dhcp/dhclient-exit-hooks.d/chrony + cp /tmp/chrony-specific/10-dhcp-chrony /mnt/etc/NetworkManager/dispatcher.d/ + chmod +x /mnt/etc/NetworkManager/dispatcher.d/10-dhcp-chrony fi