forked from tfgrid/zosbuilder
zinit: stabilize ntp/network/getty runtime
• ntp: robust /etc/ntp.conf symlink, safe defaults, avoid nounset, keep BusyBox CLI -p usage • network: wrap dhcpcd to create dhcpcd user/group if missing; run as root if needed • console: set getty console to 115200 vt100
This commit is contained in:
@@ -21,6 +21,7 @@ util-linux
|
|||||||
# Essential networking (for Zero-OS connectivity)
|
# Essential networking (for Zero-OS connectivity)
|
||||||
iproute2
|
iproute2
|
||||||
ethtool
|
ethtool
|
||||||
|
nftables
|
||||||
|
|
||||||
# Filesystem support (minimal)
|
# Filesystem support (minimal)
|
||||||
btrfs-progs
|
btrfs-progs
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
exec: /sbin/getty console
|
exec: /sbin/getty -L 115200 console vt100
|
||||||
restart: always
|
restart: always
|
||||||
7
config/zinit/init/network.sh
Executable file
7
config/zinit/init/network.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
# Ensure dhcpcd user/group exist (some builds expect to drop privileges)
|
||||||
|
if ! getent group dhcpcd >/dev/null 2>&1; then addgroup -S dhcpcd 2>/dev/null || true; fi
|
||||||
|
if ! getent passwd dhcpcd >/dev/null 2>&1; then adduser -S -H -D -s /sbin/nologin -G dhcpcd dhcpcd 2>/dev/null || true; fi
|
||||||
|
# Exec dhcpcd (will run as root if it cannot drop to dhcpcd user)
|
||||||
|
exec dhcpcd ""
|
||||||
@@ -1,10 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
ntp_flags=$(grep -o 'ntp=.*' /proc/cmdline | sed 's/^ntp=//')
|
# Ensure /etc/ntp.conf exists for tools/hooks expecting it
|
||||||
|
if [ -f /etc/ntpd.conf ] && [ ! -e /etc/ntp.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=""
|
||||||
|
|
||||||
params=""
|
params=""
|
||||||
if [ -n "$ntp_flags" ]; then
|
if [ -n "" ]; then
|
||||||
params=$(echo "-p $ntp_flags" | sed s/,/' -p '/g)
|
# Convert comma-separated list into multiple -p args
|
||||||
|
params="-p "
|
||||||
|
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
|
fi
|
||||||
|
|
||||||
exec ntpd -n $params
|
# BusyBox ntpd uses -p servers on CLI; /etc/ntp.conf symlink above helps alternative daemons.
|
||||||
|
exec ntpd -n
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
exec: dhcpcd eth0
|
exec: sh /etc/zinit/init/network.sh eth0
|
||||||
after:
|
after:
|
||||||
- depmod
|
- depmod
|
||||||
- udevd
|
- udevd
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
exec: /etc/zinit/init/shm.sh
|
exec: /etc/zinit/init/shm.sh
|
||||||
oneshot: true
|
oneshot: true
|
||||||
|
after:
|
||||||
|
- firmware
|
||||||
|
- modules
|
||||||
@@ -108,3 +108,5 @@ File: [scripts/lib/testing.sh](scripts/lib/testing.sh)
|
|||||||
- [testing_cloud_hypervisor_serial()](scripts/lib/testing.sh:206)
|
- [testing_cloud_hypervisor_serial()](scripts/lib/testing.sh:206)
|
||||||
- [testing_analyze_boot_log()](scripts/lib/testing.sh:227)
|
- [testing_analyze_boot_log()](scripts/lib/testing.sh:227)
|
||||||
- [testing_run_all()](scripts/lib/testing.sh:299)
|
- [testing_run_all()](scripts/lib/testing.sh:299)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user