From d2a571b58d1fc89633246831984b2515c543fb3c Mon Sep 17 00:00:00 2001 From: lda Date: Fri, 9 Oct 2026 23:53:20 +0700 Subject: [PATCH] Preserve agent setup errors and make UCI credential entry portable --- docs/openwrt-uci.md | 21 +++++++++++++++------ wakey-agent/src/main.rs | 8 +++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/openwrt-uci.md b/docs/openwrt-uci.md index 116bfdd..0bfa82c 100644 --- a/docs/openwrt-uci.md +++ b/docs/openwrt-uci.md @@ -51,15 +51,24 @@ config service 'main' ``` The example above uses a placeholder. Avoid typing real credentials into a -command that your shell will save in history. On OpenWrt's ash, you can instead +command that your shell will save in history. In an interactive SSH terminal, you can read the Basic header without echoing it and send it to UCI over stdin: ```sh -read -r -s -p 'Complete Basic authorization header: ' authorization -printf '\n' -printf "set wakey.main.otlp_authorization='%s'\ncommit wakey\n" "$authorization" | uci batch -unset authorization -chmod 600 /etc/config/wakey +( + set -e + terminal_state=$(stty -g /dev/tty + stty -echo /dev/tty + printf "set wakey.main.otlp_authorization='%s'\ncommit wakey\n" "$authorization" | uci batch + chmod 600 /etc/config/wakey +) ``` Use a normal `Basic ` header here, without quotes/newlines inside the value. diff --git a/wakey-agent/src/main.rs b/wakey-agent/src/main.rs index bea0064..0f60d68 100644 --- a/wakey-agent/src/main.rs +++ b/wakey-agent/src/main.rs @@ -19,7 +19,13 @@ async fn main() -> Result<()> { // Only the long-lived daemon exports: hotplug/enroll invocations stay cheap. let daemon_config = if let Command::Serve(args) = &cli.command { - Some(config::load_config(global_config.unwrap_or(&args.config))?) + let path = global_config.unwrap_or(&args.config); + // Let serve report its enrollment/setup instructions for a missing file. + if path.exists() { + Some(config::load_config(path)?) + } else { + None + } } else { None };