From 9f6a4021b54ce23a0812ea617102aafe3807cc63 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Wed, 7 Oct 2020 18:24:07 +0300 Subject: [PATCH] Replace ntpd with chrony * /etc/init.d/S50date: use chrony instead of ntpd * Enable chrony * cleanups.sh: remove chrony init script --- board/common/cleanups.sh | 1 + board/common/overlay/etc/init.d/S50date | 28 ++++++++++--------------- board/common/overlay/etc/ntp.conf | 20 ++++++------------ configs/bananapim1_defconfig | 2 ++ configs/nanopineo2_defconfig | 2 ++ configs/nanopineo_defconfig | 2 ++ configs/nanopir1_defconfig | 2 ++ configs/odroidxu4_defconfig | 2 ++ configs/orangepione_defconfig | 2 ++ configs/orangepizero_defconfig | 2 ++ configs/raspberrypi2_defconfig | 2 ++ configs/raspberrypi3_defconfig | 2 ++ configs/raspberrypi4_defconfig | 2 ++ configs/raspberrypi_defconfig | 2 ++ configs/tinkerboard_defconfig | 2 ++ 15 files changed, 42 insertions(+), 31 deletions(-) diff --git a/board/common/cleanups.sh b/board/common/cleanups.sh index 4623c820737..9f6f29a0409 100755 --- a/board/common/cleanups.sh +++ b/board/common/cleanups.sh @@ -210,6 +210,7 @@ rm -f ${TARGET}/etc/init.d/S20urandom rm -f ${TARGET}/etc/init.d/S21rngd rm -f ${TARGET}/etc/init.d/S48sntp rm -f ${TARGET}/etc/init.d/S49ntp +rm -f ${TARGET}/etc/init.d/S49chrony rm -f ${TARGET}/etc/init.d/S50sshd rm -f ${TARGET}/etc/init.d/S50proftpd rm -f ${TARGET}/etc/init.d/S50postgresql diff --git a/board/common/overlay/etc/init.d/S50date b/board/common/overlay/etc/init.d/S50date index ec434993d6c..f32451a78bc 100755 --- a/board/common/overlay/etc/init.d/S50date +++ b/board/common/overlay/etc/init.d/S50date @@ -1,7 +1,7 @@ #!/bin/bash PROG_DATE="/bin/date" -PROG_NTPD="/usr/sbin/ntpd" +PROG_NTPD="/usr/sbin/chronyd" PROG_SNTP="/usr/bin/sntp" LOG_SNTP="/var/log/sntp.log" @@ -47,7 +47,11 @@ set_current_date_http() { } set_current_date_ntp() { - ${PROG_NTPD} -gq &>/dev/null + if [[ -n "${DATE_NTP_SERVER}" ]]; then + sed -i "s/pool .*/pool ${DATE_NTP_SERVER} iburst/" ${NTP_CONF} + fi + + ${PROG_NTPD} -f ${NTP_CONF} -q -t ${DATE_TIMEOUT} &>/dev/null if [[ $? == 0 ]]; then logger -t date "current system date/time set to $(date) via NTP" return 0 @@ -58,8 +62,8 @@ set_current_date_ntp() { } set_current_date_sntp() { - sntp_args="-t ${DATE_TIMEOUT} -K /var/lib/ntp/kod -Ss" - server=$(cat ${NTP_CONF} | grep server | head -n 1 | cut -d ' ' -f 2) + sntp_args="-t ${DATE_TIMEOUT} -K /dev/null -Ss" + server=$(cat ${NTP_CONF} | grep pool | head -n 1 | cut -d ' ' -f 2) ${PROG_SNTP} ${sntp_args} ${server} &>${LOG_SNTP} if [[ $? == 0 ]]; then logger -t date "current system date/time set to $(date) via SNTP" @@ -94,32 +98,22 @@ start_http() { } start_ntp() { - mkdir -p /var/lib/ntp - touch /var/lib/ntp/kod - - cat ${NTP_CONF} | grep -v iburst > ${NTP_CONF}.tmp - if [[ -n "${DATE_NTP_SERVER}" ]]; then - echo "server ${DATE_NTP_SERVER} iburst" > ${NTP_CONF} - else - cat ${SYS_NTP_CONF} | grep iburst > ${NTP_CONF} + sed -i "s/pool .*/pool ${DATE_NTP_SERVER} iburst/" ${NTP_CONF} fi - cat ${NTP_CONF}.tmp >> ${NTP_CONF} - rm ${NTP_CONF}.tmp - if [[ "${DATE_METHOD}" == "sntp" ]]; then msg_begin "Setting current date using SNTP" set_current_date_sntp test $? == 0 && msg_done "$(${PROG_DATE})" || msg_fail else # assuming ntp msg_begin "Setting current date using NTP" - set_current_date_ntp || set_current_date_ntp + set_current_date_ntp test $? == 0 && msg_done "$(${PROG_DATE})" || msg_fail fi msg_begin "Starting ntpd" - ${PROG_NTPD} -g -c ${NTP_CONF} + ${PROG_NTPD} -f ${NTP_CONF} test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/ntp.conf b/board/common/overlay/etc/ntp.conf index 55e387c0a84..75ee7fa6f48 100644 --- a/board/common/overlay/etc/ntp.conf +++ b/board/common/overlay/etc/ntp.conf @@ -1,14 +1,6 @@ -tinker panic 0 - -server 0.pool.ntp.org iburst -server 1.pool.ntp.org iburst -server 2.pool.ntp.org iburst - -server 127.127.1.0 -fudge 127.127.1.0 stratum 10 - -restrict default noquery nopeer -restrict 127.0.0.1 -restrict ::1 - -driftfile /var/lib/ntp/ntp.drift +pool pool.ntp.org iburst +driftfile /var/lib/chrony.drift +makestep 1000 10 +rtcsync +hwclockfile /data/etc/adjtime +log tracking diff --git a/configs/bananapim1_defconfig b/configs/bananapim1_defconfig index 3298da7642b..37ab3598974 100644 --- a/configs/bananapim1_defconfig +++ b/configs/bananapim1_defconfig @@ -59,6 +59,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -69,6 +70,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/nanopineo2_defconfig b/configs/nanopineo2_defconfig index 20c9d03f57a..e3c1cae69fd 100644 --- a/configs/nanopineo2_defconfig +++ b/configs/nanopineo2_defconfig @@ -51,6 +51,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -61,6 +62,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/nanopineo_defconfig b/configs/nanopineo_defconfig index 53f07209217..8f5e92d4c9e 100644 --- a/configs/nanopineo_defconfig +++ b/configs/nanopineo_defconfig @@ -51,6 +51,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -61,6 +62,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/nanopir1_defconfig b/configs/nanopir1_defconfig index 41f07e856eb..68fce1c4fd0 100644 --- a/configs/nanopir1_defconfig +++ b/configs/nanopir1_defconfig @@ -52,6 +52,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -62,6 +63,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/odroidxu4_defconfig b/configs/odroidxu4_defconfig index 6b2bbdfad40..6ff04e1089a 100644 --- a/configs/odroidxu4_defconfig +++ b/configs/odroidxu4_defconfig @@ -54,6 +54,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -64,6 +65,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/orangepione_defconfig b/configs/orangepione_defconfig index f2028b7e1ac..0ba92076d72 100644 --- a/configs/orangepione_defconfig +++ b/configs/orangepione_defconfig @@ -54,6 +54,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -64,6 +65,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/orangepizero_defconfig b/configs/orangepizero_defconfig index 8ea39617222..c9110ec35b3 100644 --- a/configs/orangepizero_defconfig +++ b/configs/orangepizero_defconfig @@ -54,6 +54,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -64,6 +65,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/raspberrypi2_defconfig b/configs/raspberrypi2_defconfig index f67033dc9b3..978ebacf208 100644 --- a/configs/raspberrypi2_defconfig +++ b/configs/raspberrypi2_defconfig @@ -57,6 +57,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -67,6 +68,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig index 644695b78e4..f71faf89eaa 100644 --- a/configs/raspberrypi3_defconfig +++ b/configs/raspberrypi3_defconfig @@ -57,6 +57,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -67,6 +68,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/raspberrypi4_defconfig b/configs/raspberrypi4_defconfig index a8a95edefbe..363d5da2fee 100644 --- a/configs/raspberrypi4_defconfig +++ b/configs/raspberrypi4_defconfig @@ -57,6 +57,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -67,6 +68,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/raspberrypi_defconfig b/configs/raspberrypi_defconfig index f1d5ac8893c..3d842516887 100644 --- a/configs/raspberrypi_defconfig +++ b/configs/raspberrypi_defconfig @@ -64,6 +64,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -74,6 +75,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y diff --git a/configs/tinkerboard_defconfig b/configs/tinkerboard_defconfig index 71f431bad7a..f9ade6750d3 100644 --- a/configs/tinkerboard_defconfig +++ b/configs/tinkerboard_defconfig @@ -55,6 +55,7 @@ BR2_PACKAGE_PCRE=y BR2_PACKAGE_PCRE_UCP=y BR2_PACKAGE_SEMVER_SORT=y BR2_PACKAGE_AUTOSSH=y +BR2_PACKAGE_CHRONY=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DHCP=y BR2_PACKAGE_DHCP_CLIENT=y @@ -65,6 +66,7 @@ BR2_PACKAGE_NET_TOOLS=y BR2_PACKAGE_NETCAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_NTP_SNTP=y +# BR2_PACKAGE_NTP_NTPD is not set BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PPPD=y BR2_PACKAGE_WIRELESS_TOOLS=y