From b5ad20ce51fc1143e491ad333a3d22f7c6d4cfad Mon Sep 17 00:00:00 2001 From: ansible Date: Tue, 7 Apr 2026 16:00:16 +0000 Subject: [PATCH] Fix chroot DNS and mkfs.ext4 path for remote deployment - Copy host /etc/resolv.conf into chroot before apk install (fixes DNS) - Set static DNS (8.8.8.8) after chroot install for runtime - Use PATH-based mkfs.ext4 instead of hardcoded /usr/sbin/ - Show chroot package install output (stdio: inherit) Co-Authored-By: Claude Opus 4.6 (1M context) --- src/setup.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/setup.ts b/src/setup.ts index ca44f3a..acf6253 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -68,7 +68,7 @@ export async function runSetup() { execFileSync("truncate", ["-s", "256M", CONFIG.baseRootfs], { stdio: "pipe", }); - execFileSync("sudo", ["/usr/sbin/mkfs.ext4", "-q", CONFIG.baseRootfs], { + execFileSync("sudo", ["mkfs.ext4", "-q", CONFIG.baseRootfs], { stdio: "pipe", }); execFileSync("sudo", ["mount", CONFIG.baseRootfs, ext4Mount], { @@ -78,9 +78,9 @@ export async function runSetup() { stdio: "pipe", }); - // DNS + // DNS — copy host resolv.conf for chroot package install, then set static execSync( - `echo "nameserver 8.8.8.8" | sudo tee ${ext4Mount}/etc/resolv.conf > /dev/null` + `sudo cp /etc/resolv.conf ${ext4Mount}/etc/resolv.conf` ); // Inittab for serial console @@ -112,7 +112,12 @@ EOF`); "rc-update add sshd default && ssh-keygen -A && " + "echo 'PermitRootLogin prohibit-password' >> /etc/ssh/sshd_config && " + "mkdir -p /run/openrc && touch /run/openrc/softlevel"], - { stdio: "pipe", timeout: 120_000 } + { stdio: "inherit", timeout: 120_000 } + ); + + // Set static DNS for runtime (replace host resolv.conf used during install) + execSync( + `echo "nameserver 8.8.8.8" | sudo tee ${ext4Mount}/etc/resolv.conf > /dev/null` ); // Networking init script