Preserve agent setup errors and make UCI credential entry portable
This commit is contained in:
2 files changed
+22
-7
No files matched your search
+15
-6
@@ -51,15 +51,24 @@ config service 'main'
|
|||||||
```
|
```
|
||||||
|
|
||||||
The example above uses a placeholder. Avoid typing real credentials into a
|
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:
|
read the Basic header without echoing it and send it to UCI over stdin:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
read -r -s -p 'Complete Basic authorization header: ' authorization
|
(
|
||||||
printf '\n'
|
set -e
|
||||||
printf "set wakey.main.otlp_authorization='%s'\ncommit wakey\n" "$authorization" | uci batch
|
terminal_state=$(stty -g </dev/tty)
|
||||||
unset authorization
|
# Restore the original terminal settings even on failure or interruption.
|
||||||
chmod 600 /etc/config/wakey
|
trap 'stty "$terminal_state" </dev/tty' 0
|
||||||
|
trap 'exit 1' HUP INT TERM
|
||||||
|
printf 'Complete Basic authorization header: ' >/dev/tty
|
||||||
|
stty -echo </dev/tty
|
||||||
|
IFS= read -r authorization </dev/tty
|
||||||
|
stty "$terminal_state" </dev/tty
|
||||||
|
printf '\n' >/dev/tty
|
||||||
|
printf "set wakey.main.otlp_authorization='%s'\ncommit wakey\n" "$authorization" | uci batch
|
||||||
|
chmod 600 /etc/config/wakey
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Use a normal `Basic <base64>` header here, without quotes/newlines inside the value.
|
Use a normal `Basic <base64>` header here, without quotes/newlines inside the value.
|
||||||
|
|||||||
@@ -19,7 +19,13 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
// Only the long-lived daemon exports: hotplug/enroll invocations stay cheap.
|
// Only the long-lived daemon exports: hotplug/enroll invocations stay cheap.
|
||||||
let daemon_config = if let Command::Serve(args) = &cli.command {
|
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 {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user