initramfs: use /etc/ntp.conf (with ntpd.conf symlink), fix CPIO redirection, add customization logs

• scripts/lib/initramfs.sh: write /etc/ntp.conf, symlink ntpd.conf if absent; compute absolute output path before cd so cpio|xz redirection works; emit verification logs around initramfs_finalize_customization()

• config/zinit/init/ntpd.sh: robust parsing of kernel ntp=, safe defaults, and launch BusyBox ntpd with -p servers
This commit is contained in:
2025-09-09 09:41:34 +02:00
parent 9aecfe26ac
commit 36190f6704
4 changed files with 64 additions and 27 deletions

View File

@@ -1,24 +1,24 @@
#!/bin/sh
set -e
set -eu
# Ensure /etc/ntp.conf exists for tools/hooks expecting it
if [ -f /etc/ntpd.conf ] && [ ! -e /etc/ntp.conf ]; then
if [ ! -e /etc/ntp.conf ] && [ -f /etc/ntpd.conf ]; then
ln -sf /etc/ntpd.conf /etc/ntp.conf
fi
# dhcpcd hook may write into /var/lib/ntp
mkdir -p /var/lib/ntp
# Extract ntp=... from kernel cmdline if present
ntp_flags=""
ntp_flags="$(grep -o 'ntp=[^ ]*' /proc/cmdline 2>/dev/null | sed 's/^ntp=//' || true)"
params=""
if [ -n "" ]; then
if [ -n "${ntp_flags}" ]; then
# Convert comma-separated list into multiple -p args
params="-p "
params="-p $(printf '%s' "${ntp_flags}" | sed 's/,/ -p /g')"
else
# Sensible defaults when no ntp= is provided
params="-p time.google.com -p time1.google.com -p time2.google.com -p time3.google.com"
fi
# BusyBox ntpd uses -p servers on CLI; /etc/ntp.conf symlink above helps alternative daemons.
exec ntpd -n
exec ntpd -n ${params}