From cb2915a11d50a98e36ad2600ed0527c74178c680 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 18 Jan 2018 15:08:35 +0100 Subject: [PATCH] v6.0 + Switch NTP config to "pool" directive: https://serverfault.com/a/773234 + Use sed to leave directives in place. --- dietpi/func/dietpi-set_software | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/dietpi/func/dietpi-set_software b/dietpi/func/dietpi-set_software index ed0b0ca856..bf9f0bbb5f 100644 --- a/dietpi/func/dietpi-set_software +++ b/dietpi/func/dietpi-set_software @@ -214,11 +214,23 @@ _EOF_ fi # - Set NTPD mirror - sed -i '/^server [0-9]/d' /etc/ntp.conf - for ((i=0; i<4; i++)) - do + # - Remove obsolete 'server' entries. + sed -i '/^[[:blank:]#;]*server [0-9]/d' /etc/ntp.conf + for ((i=0; i<4; i++)) do - echo -e "server $i.$ntpd_mirror iburst" >> /etc/ntp.conf + if grep "^[[:blank:]]*pool $i" /etc/ntp.conf; then + + sed -i "s/^[[:blank:]]*pool $i.*/pool $i.$ntpd_mirror iburst/" /etc/ntp.conf + + elif grep "^[[:blank:]#;]*pool $i" /etc/ntp.conf; then + + sed -i "s/^[[:blank:]#;]*pool $i.*/pool $i.$ntpd_mirror iburst/" /etc/ntp.conf + + else + + echo -e "pool $i.$ntpd_mirror iburst" >> /etc/ntp.conf + + fi done