From 7ce500c35756217db76923fbd1c904cd9d4edb4f Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 6 Apr 2026 11:31:44 -0600 Subject: [PATCH 1/9] Enable ntp if autodetect ntpd or timesyncd If --enable-ntpd or --enable-timesyncd, assume --enable-ntp and choose the appropriate hook file. Will complain if --enable-ntpd or --enable-timesyncd are both set, allows override of autodetect. Autodetect will enable ntp functionality unless explicitly told not to via --disable-ntp. If --disable-ntp is used, no time hooks are installed. Addresses #574 --- configure | 106 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/configure b/configure index e9c08f18..fd972be8 100755 --- a/configure +++ b/configure @@ -39,6 +39,9 @@ SMALL= SANITIZE=no STATUSARG= OPENSSL= +NTPD= +CHRONYD= +TIMESYNCD= DHCPCD_DEFS=dhcpcd-definitions.conf @@ -77,6 +80,8 @@ for x do --enable-seccomp) SECCOMP=yes;; --disable-ntp) NTP=no;; --enable-ntp) NTP=yes;; + --enable-ntpd) NTPD=yes; NTP=yes;; + --enable-timesyncd) TIMESYNCD=yes; NTP=yes;; --privsepuser) PRIVSEP_USER=$var;; --prefix) PREFIX=$var;prefix=$var;; # prefix is set for autotools compat --sysconfdir) SYSCONFDIR=$var;; @@ -1698,41 +1703,57 @@ echo "STATUSARG= $STATUSARG" >>config.mk HOOKS= if ! $HOOKSET; then - printf "Checking for ntpd ... " - NTPD=$(_which ntpd) - if [ -n "$NTPD" ]; then - echo "$NTPD (50-ntp.conf)" - else - echo "not found" - fi - printf "Checking for chronyd ... " - CHRONYD=$(_which chronyd) - if [ -n "$CHRONYD" ]; then - echo "$CHRONYD (50-ntp.conf)" - else - echo "not found" - fi - if [ -n "$NTPD" ] || [ -n "$CHRONYD" ]; then - HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf" - fi - # Warn if both are detected - if [ -n "$NTPD" ] && [ -n "$CHRONYD" ]; then - echo "NTP will default to $NTPD" - fi + if ! [ "$NTP" = "no" ]; then + if [ "$NTPD" = "yes" ] && [ "$TIMESYNCD" = "yes" ]; then + echo "Warning: --enable-ntpd and --enable-timesyncd are both set" >&2 + exit 1 + fi + printf "Checking for ntpd ... " + NTPD_PATH=$(_which ntpd) + if [ -n "$NTPD_PATH" ]; then + NTPD=yes + NTP=yes + echo "$NTPD_PATH (Selecting 50-ntp.conf)" + else + echo "not found" + fi + printf "Checking for chronyd ... " + CHRONYD_PATH=$(_which chronyd) + if [ -n "$CHRONYD_PATH" ]; then + NTPD=yes + NTP=yes + echo "$CHRONYD_PATH (Selecting 50-ntp.conf)" + else + echo "not found" + fi + + # Warn if both are detected + if [ -n "$NTPD_PATH" ] && [ -n "$CHRONYD_PATH" ]; then + echo "NTP will default to $NTPD_PATH" + fi - printf "Checking for timesyncd ... " - TIMESYNCD= - for x in /usr/lib/systemd/systemd-timesyncd; do - if [ -x "$x" ]; then - TIMESYNCD=$x - break + printf "Checking for timesyncd ... " + TIMESYNCD_PATH= + for x in /usr/lib/systemd/systemd-timesyncd; do + if [ -x "$x" ]; then + TIMESYNCD=yes + TIMESYNCD_PATH=$x + NTP=yes + break + fi + done + if [ "$TIMESYNCD" = "yes" ]; then + echo "$TIMESYNCD_PATH (Selecting 50-timesyncd.conf)" + else + echo "not found" + fi + + # Choose hook based on enabled time service + if [ "$NTPD" = "yes" ]; then + HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf" + elif [ "$TIMESYNCD" = "yes" ]; then + HOOKS="$HOOKS${HOOKS:+ }50-timesyncd.conf" fi - done - if [ -n "$TIMESYNCD" ]; then - echo "$TIMESYNCD" - HOOKS="$HOOKS${HOOKS:+ }50-timesyncd.conf" - else - echo "not found" fi printf "Checking for ypbind ... " @@ -1790,9 +1811,24 @@ if ! $HOOKSET; then fi fi fi -if [ "$NTP" = yes ]; then - # --enable-ntp + +if [ -z "$NTP" ]; then + if [ "$NTPD" = "yes" ] || [ "$TIMESYNCD" = "yes" ]; then + NTP=yes + fi +fi +if [ "$NTP" = "yes" ]; then + # --enable-ntp or ntp/timesyncd service was autodetected + printf "Enabling NTP support for ... " + if [ "$NTPD" = "yes" ]; then + echo "ntpd" + elif [ "$TIMESYNCD" = "yes" ]; then + echo "timesyncd" + fi echo "UNCOMMENT_NTP= yes" >>$CONFIG_MK +else + # --disable-ntp + echo "NTP support is disabled" fi echo >>$CONFIG_H From b33ce6abfa4fd3b806cd5c688d261bff9cd2f8d2 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 6 Apr 2026 14:05:06 -0600 Subject: [PATCH 2/9] Check for conflict time server detection outside HOOKSET Addressing AI review comments. --- configure | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/configure b/configure index fd972be8..ce44219f 100755 --- a/configure +++ b/configure @@ -40,7 +40,6 @@ SANITIZE=no STATUSARG= OPENSSL= NTPD= -CHRONYD= TIMESYNCD= DHCPCD_DEFS=dhcpcd-definitions.conf @@ -1701,13 +1700,14 @@ if [ -z "$STATUSARG" ]; then fi echo "STATUSARG= $STATUSARG" >>config.mk +if [ "$NTPD" = "yes" ] && [ "$TIMESYNCD" = "yes" ]; then + echo "Warning: --enable-ntpd and --enable-timesyncd are both set" >&2 + exit 1 +fi + HOOKS= if ! $HOOKSET; then if ! [ "$NTP" = "no" ]; then - if [ "$NTPD" = "yes" ] && [ "$TIMESYNCD" = "yes" ]; then - echo "Warning: --enable-ntpd and --enable-timesyncd are both set" >&2 - exit 1 - fi printf "Checking for ntpd ... " NTPD_PATH=$(_which ntpd) if [ -n "$NTPD_PATH" ]; then @@ -1748,6 +1748,11 @@ if ! $HOOKSET; then echo "not found" fi + # Warn if both ntpd/chronyd and timesyncd are detected + if [ "$NTPD" = "yes" ] && [ -n "$TIMESYNCD_PATH" ]; then + echo "Both ntpd/chronyd and timesyncd detected; NTP will default to ntpd" + fi + # Choose hook based on enabled time service if [ "$NTPD" = "yes" ]; then HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf" From 5b5a103e13db0271de199756212650c75b77a56d Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 6 Apr 2026 14:19:05 -0600 Subject: [PATCH 3/9] Allow ntpd and timesyncd to be disabled Skips autodetection. --- configure | 83 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/configure b/configure index ce44219f..27b16fa5 100755 --- a/configure +++ b/configure @@ -40,6 +40,7 @@ SANITIZE=no STATUSARG= OPENSSL= NTPD= +CHRONYD= TIMESYNCD= DHCPCD_DEFS=dhcpcd-definitions.conf @@ -79,7 +80,9 @@ for x do --enable-seccomp) SECCOMP=yes;; --disable-ntp) NTP=no;; --enable-ntp) NTP=yes;; + --disable-ntpd) NTPD=no;; --enable-ntpd) NTPD=yes; NTP=yes;; + --disable-timesyncd) TIMESYNCD=no;; --enable-timesyncd) TIMESYNCD=yes; NTP=yes;; --privsepuser) PRIVSEP_USER=$var;; --prefix) PREFIX=$var;prefix=$var;; # prefix is set for autotools compat @@ -1708,47 +1711,57 @@ fi HOOKS= if ! $HOOKSET; then if ! [ "$NTP" = "no" ]; then - printf "Checking for ntpd ... " - NTPD_PATH=$(_which ntpd) - if [ -n "$NTPD_PATH" ]; then - NTPD=yes - NTP=yes - echo "$NTPD_PATH (Selecting 50-ntp.conf)" - else - echo "not found" - fi - printf "Checking for chronyd ... " - CHRONYD_PATH=$(_which chronyd) - if [ -n "$CHRONYD_PATH" ]; then - NTPD=yes - NTP=yes - echo "$CHRONYD_PATH (Selecting 50-ntp.conf)" - else - echo "not found" - fi - - # Warn if both are detected - if [ -n "$NTPD_PATH" ] && [ -n "$CHRONYD_PATH" ]; then - echo "NTP will default to $NTPD_PATH" + printf "Checking for ntpd ... " + if [ -z "$NTPD" ]; then + # if not explicitly set enable/disable, try to autodetect + + NTPD_PATH=$(_which ntpd) + if [ -n "$NTPD_PATH" ]; then + NTPD=yes + NTP=yes + echo "$NTPD_PATH (Selecting 50-ntp.conf)" + else + echo "not found" + fi + printf "Checking for chronyd ... " + CHRONYD_PATH=$(_which chronyd) + if [ -n "$CHRONYD_PATH" ]; then + NTPD=yes + NTP=yes + echo "$CHRONYD_PATH (Selecting 50-ntp.conf)" + else + echo "not found" + fi + + # Warn if both are detected + if [ -n "$NTPD_PATH" ] && [ -n "$CHRONYD_PATH" ]; then + echo "NTP will default to $NTPD_PATH" + fi + elif [ "$NTPD" = "no" ]; then + echo "skipped" fi printf "Checking for timesyncd ... " - TIMESYNCD_PATH= - for x in /usr/lib/systemd/systemd-timesyncd; do - if [ -x "$x" ]; then - TIMESYNCD=yes - TIMESYNCD_PATH=$x - NTP=yes - break + if [ -z "$TIMESYNCD" ]; then + TIMESYNCD_PATH= + for x in /usr/lib/systemd/systemd-timesyncd; do + if [ -x "$x" ]; then + TIMESYNCD=yes + TIMESYNCD_PATH=$x + NTP=yes + break + fi + done + if [ "$TIMESYNCD" = "yes" ]; then + echo "$TIMESYNCD_PATH (Selecting 50-timesyncd.conf)" + else + echo "not found" fi - done - if [ "$TIMESYNCD" = "yes" ]; then - echo "$TIMESYNCD_PATH (Selecting 50-timesyncd.conf)" - else - echo "not found" + elif [ "$TIMESYNCD" = "no" ]; then + echo "skipped" fi - # Warn if both ntpd/chronyd and timesyncd are detected + # Warn if both ntpd/chronyd and timesyncd are detected if [ "$NTPD" = "yes" ] && [ -n "$TIMESYNCD_PATH" ]; then echo "Both ntpd/chronyd and timesyncd detected; NTP will default to ntpd" fi From 5f15761160ada460ad54162d4f9edb085c8c234f Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 6 Apr 2026 14:23:48 -0600 Subject: [PATCH 4/9] Update configure to indicate which time service was used enabled ntpd/chrony, timesyncd, or other HOOKSCRIPT method. --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 27b16fa5..16b3fd7f 100755 --- a/configure +++ b/configure @@ -1842,6 +1842,8 @@ if [ "$NTP" = "yes" ]; then echo "ntpd" elif [ "$TIMESYNCD" = "yes" ]; then echo "timesyncd" + else + echo "user defined time service via HOOKSCRIPTS" fi echo "UNCOMMENT_NTP= yes" >>$CONFIG_MK else From 237351192c0d5c8d98266deb29f563d55adc26dc Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 6 Apr 2026 14:28:07 -0600 Subject: [PATCH 5/9] Disable autodetect of other time service if enable is used Service selection should disable autodetect of the other service. --- configure | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure b/configure index 16b3fd7f..ac2852a5 100755 --- a/configure +++ b/configure @@ -1711,6 +1711,14 @@ fi HOOKS= if ! $HOOKSET; then if ! [ "$NTP" = "no" ]; then + # Explicit service selection should disable autodetect of the other service. + if [ "$TIMESYNCD" = "yes" ] && [ -z "$NTPD" ]; then + NTPD=no + fi + if [ "$NTPD" = "yes" ] && [ -z "$TIMESYNCD" ]; then + TIMESYNCD=no + fi + printf "Checking for ntpd ... " if [ -z "$NTPD" ]; then # if not explicitly set enable/disable, try to autodetect From aede59692a9d297ac32f9763faea96fd5fa3f7ab Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 13 Apr 2026 11:17:08 -0600 Subject: [PATCH 6/9] Allow ntpd and timesyncd to be enabled together exit hooks determine at runtime if the required feature is present on the target system, so allow both ntpd and timesyncd to be enabled by configure so it packages both sets of exit hooks (and likewise enables ntp support in dhcpcd) --- configure | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/configure b/configure index ac2852a5..b2b18a5e 100755 --- a/configure +++ b/configure @@ -1703,22 +1703,9 @@ if [ -z "$STATUSARG" ]; then fi echo "STATUSARG= $STATUSARG" >>config.mk -if [ "$NTPD" = "yes" ] && [ "$TIMESYNCD" = "yes" ]; then - echo "Warning: --enable-ntpd and --enable-timesyncd are both set" >&2 - exit 1 -fi - HOOKS= if ! $HOOKSET; then if ! [ "$NTP" = "no" ]; then - # Explicit service selection should disable autodetect of the other service. - if [ "$TIMESYNCD" = "yes" ] && [ -z "$NTPD" ]; then - NTPD=no - fi - if [ "$NTPD" = "yes" ] && [ -z "$TIMESYNCD" ]; then - TIMESYNCD=no - fi - printf "Checking for ntpd ... " if [ -z "$NTPD" ]; then # if not explicitly set enable/disable, try to autodetect @@ -1747,6 +1734,8 @@ if ! $HOOKSET; then fi elif [ "$NTPD" = "no" ]; then echo "skipped" + else + echo "selected via --enable-ntpd (Selecting 50-ntp.conf)" fi printf "Checking for timesyncd ... " @@ -1767,17 +1756,15 @@ if ! $HOOKSET; then fi elif [ "$TIMESYNCD" = "no" ]; then echo "skipped" - fi - - # Warn if both ntpd/chronyd and timesyncd are detected - if [ "$NTPD" = "yes" ] && [ -n "$TIMESYNCD_PATH" ]; then - echo "Both ntpd/chronyd and timesyncd detected; NTP will default to ntpd" + else + echo "selected via --enable-timesyncd (Selecting 50-timesyncd.conf)" fi # Choose hook based on enabled time service if [ "$NTPD" = "yes" ]; then HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf" - elif [ "$TIMESYNCD" = "yes" ]; then + fi + if [ "$TIMESYNCD" = "yes" ]; then HOOKS="$HOOKS${HOOKS:+ }50-timesyncd.conf" fi fi @@ -1845,14 +1832,7 @@ if [ -z "$NTP" ]; then fi if [ "$NTP" = "yes" ]; then # --enable-ntp or ntp/timesyncd service was autodetected - printf "Enabling NTP support for ... " - if [ "$NTPD" = "yes" ]; then - echo "ntpd" - elif [ "$TIMESYNCD" = "yes" ]; then - echo "timesyncd" - else - echo "user defined time service via HOOKSCRIPTS" - fi + echo "Enabling NTP support" echo "UNCOMMENT_NTP= yes" >>$CONFIG_MK else # --disable-ntp From a3ef5ab58a161adea3f110e9419f88d17898cfa7 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 14 Apr 2026 12:22:40 -0600 Subject: [PATCH 7/9] Search /lib and /usr/lib for timesyncd --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b2b18a5e..67ae4097 100755 --- a/configure +++ b/configure @@ -1741,7 +1741,8 @@ if ! $HOOKSET; then printf "Checking for timesyncd ... " if [ -z "$TIMESYNCD" ]; then TIMESYNCD_PATH= - for x in /usr/lib/systemd/systemd-timesyncd; do + for x in /lib/systemd/systemd-timesyncd \ + /usr/lib/systemd/systemd-timesyncd; do if [ -x "$x" ]; then TIMESYNCD=yes TIMESYNCD_PATH=$x From 09ec8dfa1a8ece1afb5513c7a2371db7ce44f31c Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 14 Apr 2026 12:27:04 -0600 Subject: [PATCH 8/9] timesyncd exit hook should look in both locations /lib and /usr/lib might contain timesyncd, check both --- hooks/50-timesyncd.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/50-timesyncd.conf b/hooks/50-timesyncd.conf index f213bd8c..4c1876fa 100644 --- a/hooks/50-timesyncd.conf +++ b/hooks/50-timesyncd.conf @@ -1,7 +1,8 @@ if [ ! -d /run/systemd/system ]; then return fi -if [ ! -x /lib/systemd/systemd-timesyncd ]; then +if [ ! -x /lib/systemd/systemd-timesyncd ] && \ + [ ! -x /usr/lib/systemd/systemd-timesyncd ]; then return fi From 6ddeeae53b8502ae98edd8646049f5c6d500b006 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 14 Apr 2026 12:33:48 -0600 Subject: [PATCH 9/9] Minor nitpick updates AI recommended a few cleanup and output logging changes that make sense. Explicitly differentiate between ntp not found, and ntp disabled. --- configure | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 67ae4097..58d102ee 100755 --- a/configure +++ b/configure @@ -40,7 +40,6 @@ SANITIZE=no STATUSARG= OPENSSL= NTPD= -CHRONYD= TIMESYNCD= DHCPCD_DEFS=dhcpcd-definitions.conf @@ -1709,7 +1708,6 @@ if ! $HOOKSET; then printf "Checking for ntpd ... " if [ -z "$NTPD" ]; then # if not explicitly set enable/disable, try to autodetect - NTPD_PATH=$(_which ntpd) if [ -n "$NTPD_PATH" ]; then NTPD=yes @@ -1835,9 +1833,12 @@ if [ "$NTP" = "yes" ]; then # --enable-ntp or ntp/timesyncd service was autodetected echo "Enabling NTP support" echo "UNCOMMENT_NTP= yes" >>$CONFIG_MK -else +elif [ "$NTP" = "no" ]; then # --disable-ntp echo "NTP support is disabled" +else + # No NTP daemon detected + echo "NTP support not enabled (no daemon detected)" fi echo >>$CONFIG_H