From 06be960129ae5a301bc4912db315992a9ba9ce7b Mon Sep 17 00:00:00 2001 From: Jeffrey Alan Scudder Date: Thu, 26 Mar 2026 11:56:55 -0700 Subject: [PATCH] fix: voice off by default, poweroff from first run, udhcpc path search - Keystroke TTS disabled by default (voice_off=1) - Init script handles exit code 0/2 from first run (not just crash loop) - udhcpc searches /sbin, /bin, /usr/bin + passes default.script path - Better DHCP log messages Co-Authored-By: Claude Opus 4.6 (1M context) --- fedac/native/initramfs/init | 15 ++++++++++++++- fedac/native/src/ac-native.c | 2 +- fedac/native/src/wifi.c | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/fedac/native/initramfs/init b/fedac/native/initramfs/init index ac31b691c..1676370c0 100755 --- a/fedac/native/initramfs/init +++ b/fedac/native/initramfs/init @@ -104,8 +104,21 @@ fi # Run once, capture crash echo "[ac-init] === LAUNCHING ===" /ac-native /piece.mjs > /mnt/pre-launch-out.log 2>&1 -echo "[ac-init] EXIT=$?" +FIRST_EXIT=$? +echo "[ac-init] EXIT=$FIRST_EXIT" sync + +# Handle clean exit from first run +if [ "$FIRST_EXIT" = "0" ]; then + echo "[ac-init] Clean exit (first run) — powering off..." + echo o > /proc/sysrq-trigger 2>/dev/null + sleep 2; poweroff -f 2>/dev/null; sleep 30; exit 0 +fi +if [ "$FIRST_EXIT" = "2" ]; then + echo "[ac-init] Reboot (first run)..." + echo b > /proc/sysrq-trigger 2>/dev/null + sleep 2; reboot -f 2>/dev/null; sleep 30; exit 0 +fi sleep 5 CRASH_COUNT=0 diff --git a/fedac/native/src/ac-native.c b/fedac/native/src/ac-native.c index 0a7391bc7..15bb972ef 100644 --- a/fedac/native/src/ac-native.c +++ b/fedac/native/src/ac-native.c @@ -41,7 +41,7 @@ static volatile int running = 1; static FILE *logfile = NULL; int ac_log_stderr_muted = 0; // When set, ac_log skips stderr (PTY active) -int voice_off = 0; // When set, keystroke TTS is disabled +int voice_off = 1; // Keystroke TTS disabled by default (enable with voice:on in config) static int is_removable(const char *blkname); static void get_parent_block(const char *part, char *out, int out_sz); diff --git a/fedac/native/src/wifi.c b/fedac/native/src/wifi.c index d8e662f93..00290bcc5 100644 --- a/fedac/native/src/wifi.c +++ b/fedac/native/src/wifi.c @@ -336,13 +336,22 @@ static void wifi_do_connect(ACWifi *wifi, const char *ssid, const char *password int fd = open("/tmp/dhcp.log", O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd >= 0) { dup2(fd, 2); dup2(fd, 1); close(fd); } // Prefer udhcpc (busybox) — fast, no script needed - if (file_exists("/sbin/udhcpc")) - execl("/sbin/udhcpc", "udhcpc", "-i", wifi->iface, + const char *udhcpc = NULL; + if (file_exists("/sbin/udhcpc")) udhcpc = "/sbin/udhcpc"; + else if (file_exists("/bin/udhcpc")) udhcpc = "/bin/udhcpc"; + else if (file_exists("/usr/bin/udhcpc")) udhcpc = "/usr/bin/udhcpc"; + if (udhcpc) { + fprintf(stderr, "[wifi] using udhcpc: %s\n", udhcpc); + execl(udhcpc, "udhcpc", "-i", wifi->iface, "-n", // exit if no lease (don't background) "-q", // quit after obtaining lease + "-s", "/usr/share/udhcpc/default.script", "-t", "5", // 5 retries "-T", "3", // 3 second timeout NULL); + // execl failed + fprintf(stderr, "[wifi] udhcpc execl failed: %s\n", strerror(errno)); + } // Fallback to dhclient const char *dhc_paths[] = { "/sbin/dhclient", "/usr/sbin/dhclient", NULL @@ -402,14 +411,14 @@ static void wifi_do_connect(ACWifi *wifi, const char *ssid, const char *password pclose(ifp); } - // Check if dhclient died + // Check if DHCP client died if (wifi->dhcp_pid > 0) { int status; pid_t r = waitpid(wifi->dhcp_pid, &status, WNOHANG); if (r > 0) { if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { - wifi_log(wifi, "dhclient exit %d", WEXITSTATUS(status)); - FILE *dlog = fopen("/tmp/dhclient.log", "r"); + wifi_log(wifi, "DHCP exit %d", WEXITSTATUS(status)); + FILE *dlog = fopen("/tmp/dhcp.log", "r"); if (dlog) { char dline[256]; while (fgets(dline, sizeof(dline), dlog)) -- 2.51.2