Refactor: rig bridge readme updates/install scripts refactor#896
Refactor: rig bridge readme updates/install scripts refactor#896ceotjoe wants to merge 7 commits intoaccius:Stagingfrom
Conversation
- Installer scripts generated in `server/routes/rig-bridge.js` now automatically resolve the configured TCP port, TLS scheme, and bindAddress configuration dynamically. - Refactored both Windows and macOS/Linux installer scripts to halt and interactively request user confirmation after verifying that they read the `README.md` before launching the Setup UI. - Improved subdirectory flushing using recursive deletions (`rmdir /S` and `find -exec rm -rf`) prior to repo extraction to ensure stale files do not survive updates. - Refactored Rig Bridge `README.md` text to correctly define the new installation UI behavior.
accius
left a comment
There was a problem hiding this comment.
Review — Rig Bridge installer refactor (draft)
Good direction. The dynamic port/proto/bind-address extraction and the aggressive stale-file cleanup are real improvements. A few things before moving out of draft:
Correctness
-
No timeout on "wait for listening" loops. If
node rig-bridge.jsfails to bind (permission, port in use, syntax error in the built JS), the shell loopwhile ! lsof -ti tcp:$RB_PORT …; do sleep 1; donespins forever, and the Windows:waitloopdoes the same. Please bound these (e.g. 30 iterations / 30s) and bail with a readable error + tail of node output. -
Windows: node is launched with
start /b(background, attached to console), so the user sees the "Press Enter" prompt, but there is no capture of the node PID. If node has already died by the timenetstatcheck runs,:waitloopspins forever. Same timeout concern as #1. -
Windows
:nodeloopportat end polls every 2s while the port is still listening and exits when it stops — but there is no kill path for node on Ctrl-C, and nothing actually waits on node as a process (unlike the POSIXwait $NODE_PID). If the user closes the window the node child may be orphaned. Consider usingstart /waitor simplynode rig-bridge.jsin the foreground after the browser opens. -
Linux/macOS:
opendetection afterxdg-openis fine, but some minimal Linux distros ship an unrelatedopen(from util-linux) that will not open a browser. Preferuname-gated detection:[[ "$(uname)" == "Darwin" ]] && open …. -
Three separate PowerShell invocations for port/proto/bind in the
.bat— each spawns a process (~500ms). Combine into oneConvertFrom-Jsoncall returning all three values, then parse into env vars. -
grep -Eo "[0-9]+$"to recoverRB_PORTfromSETUP_URLis brittle if the URL ever gains a path. Have the node one-liner printPORT\nURL(two lines) and read both. -
Config path fallback:
$HOME/.config/openhamclock/rig-bridge-config.jsonthen$HOME/openhamclock-rig-bridge/…. On macOS the canonical path is$HOME/Library/Application Support/openhamclock/…— is that used anywhere? If so, add it to the fallback chain. -
bindAddressfallback tolocalhostis correct for browser-open, but the0.0.0.0replacement happens only in the shell variant, not the.bat. Parity bug: Windows still buildshttp://0.0.0.0:5555when bindAddress is0.0.0.0, which does not open in a browser.
Docs
-
README "e.g., http://localhost:5555" — good. Consider also noting TLS case ("or
https://…if you enabled TLS"). -
Prerequisite block is much clearer than before — nice.
Nits
"ACK"variable set but never read; comment-only prompt. Fine, just note.- The README language ("absolutely vital", "IMPORTANT") is a bit heavy — a single "Before continuing, please read rig-bridge/README.md for radio-specific requirements." is plenty.
Happy to re-review once the timeout/parity fixes land.
Kept Staging's OS sub-section structure (Windows/macOS/Linux bullets under step 4) while applying updated installer descriptions from this branch — "prompts you to press Enter to open the Setup UI" wording and the #### heading for Option B. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Shell installer: - Bound the "wait for port" loop to 30 s; bail with readable error if node exits early (liveness check via kill -0) or times out - Print PORT and URL from the node one-liner as two space-separated fields; use `read -r RB_PORT SETUP_URL` instead of brittle grep - Add macOS Library/Application Support to config path fallback chain - Gate `open` on `[[ "$(uname)" == "Darwin" ]]` to avoid the unrelated util-linux `open` on minimal Linux distros Windows installer: - Collapse three separate PowerShell/ConvertFrom-Json invocations into one, cutting ~1.5 s of process-spawn overhead - Replace `start /b` + unbounded :waitloop + :nodeloopport with a simple `start <url>` then foreground `node rig-bridge.js` — no orphaned process, clean Ctrl-C, and no spinning loop - bindAddress 0.0.0.0 → localhost normalisation now handled inside the single PowerShell call (parity with shell installer) Both installers: - Soften "IMPORTANT / absolutely vital" banner to a single plain line README: - Note TLS variant (https://localhost:5555) alongside http example Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the thorough review — all points addressed in the latest commit. Correctness1 — Shell wait loop timeout 2 & 3 — Windows node lifecycle start %RB_PROTO%://%RB_HOST%:%RB_PORT%
node rig-bridge.js
pause
4 — 5 — Three PowerShell invocations 6 — Brittle 7 — macOS config path 8 — Docs9 — TLS note in README Nits10 — Heavy language The unused |
Combining three PowerShell calls into one required the output to use | as a field separator. CMD's for /f parser intercepts | as a pipe operator even inside double-quoted -Command strings, producing a syntax error. Revert to three separate calls (port, proto, bindAddress) which each keep their | inside a single double-quoted argument where CMD leaves it alone. The bindAddress / 0.0.0.0→localhost normalisation from the PR is preserved in the third call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
accius
left a comment
There was a problem hiding this comment.
Re-review — Rig Bridge installer refactor (still draft)
Good round of fixes. Most of the blockers from the prior pass are resolved.
Addressed well
-
Item 1, 2, 3 (timeouts / orphan processes / Ctrl-C):
- Shell: 30-iteration bounded loop,
kill -0 "$NODE_PID"liveness check,wait $NODE_PIDfor clean foreground attachment — exactly right. - Windows: the whole
:waitloop/:nodeloopportpair is replaced withstart <url>+ foregroundnode rig-bridge.js. Clean, no orphan risk, Ctrl-C kills node naturally. Much simpler.
- Shell: 30-iteration bounded loop,
-
Item 4 (
openon minimal Linux):xdg-openchecked first, then[[ "$(uname)" == "Darwin" ]] && open. Correct. -
Item 6 (brittle grep for port):
read -r RB_PORT SETUP_URL < <(node -e …)returns both fields in one shot. Much better. -
Item 7 (macOS config path):
$HOME/Library/Application Support/openhamclock/…added to the fallback chain. -
Item 8 (bindAddress 0.0.0.0 parity): normalisation now happens inside the PowerShell call too, so Windows opens
localhostnot0.0.0.0. -
Item 9 (TLS note): README mentions
https://localhost:5555alongside the HTTP example. -
Item 12 (banner tone): softened to a single "Before continuing, read rig-bridge/README.md for radio-specific setup requirements." — nicely done.
Item 5 — reverted, with reason
The combined PowerShell call was tried and reverted because | inside for /f "usebackq" gets intercepted by CMD even inside double-quoted -Command strings. The revert commit captures this correctly. Three invocations × ~500 ms is acceptable for a one-time installer; flagging this as "not worth fighting CMD quoting" is the right call.
New concerns / follow-up
-
read -rppause blocks non-interactive flows. If a user runs the installer from SSH via a deploy script or pipes it into bash, thePress Enterprompt will hang. Consider skipping it when[ ! -t 0 ](stdin not a TTY) or behind an env var likeNONINTERACTIVE=1. -
Process-substitution
< <(…)requires bash. The installer is.sh— if a user's shell is dash/ash, this breaks. Given the rest of the script already uses[[ ]], the dependency is consistent, but worth either#!/usr/bin/env bashshebang explicitly (if not already) or a POSIX-compatible rewrite using a temp file. -
Windows: 0.0.0.0 fallback in
.bat. The PowerShell expression now normalises''or'0.0.0.0'tolocalhost, but the-or $b -eq '0.0.0.0'uses PowerShell string comparison which is case-insensitive and fine. Just double-check that anullbindAddress(not a string'') also falls into theIsNullOrEmptybranch — it does (IsNullOrEmpty($null)returns true). -
Timeout error message could include last N lines of node output. Currently
echo "ERROR: Rig Bridge did not start within 30 seconds."with no diagnostic. Since node is running with inherited stdout, errors are visible above the message — so this is only a nit.
Small doc note
The Prerequisites block has grown quite long for an inline > blockquote. Consider moving it to its own small Prerequisites ### section to keep the "Option A" steps skimmable. Cosmetic, not a blocker.
Ready for un-draft?
From my side the installer is in good shape to come out of draft once you're happy with the SSH / non-interactive behaviour. The only other thing to verify is full round-trip on each OS (install fresh, update, config-port change, TLS case).
Shell installer: - Change shebang to #!/usr/bin/env bash — makes the bash dependency explicit and consistent with [[ ]] and process substitution usage - Guard the "Press Enter" prompt with [ -t 0 ] && NONINTERACTIVE!=1 so the script does not hang when run non-interactively (SSH, piped bash, deploy scripts) README: - Promote the inline Prerequisites blockquote to its own #### section between the Step 1 heading and Option A, keeping the Option A steps skimmable No changes needed for the Windows 0.0.0.0/null bindAddress point (IsNullOrEmpty($null) is true — already correct) or the timeout diagnostic nit (node stdout is inherited, errors visible above message). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks again — all actionable points addressed.
Process substitution / bash dependency Windows Timeout diagnostic Prerequisites block |
1. Remove unquoted parentheses from echo inside if-block. CMD's block-depth parser counts ALL unquoted ( ) even inside echo arguments. The balanced (updated) bumped depth to 2 then back to 1, leaving the trailing ... as an unexpected token in some CMD versions. Replaced with a plain hyphen: "Rig Bridge updated - restarting..." 2. Add empty title to start command. start <url> without an explicit "" title is incorrect CMD form — CMD can treat the URL as the window title. Changed to start "" <url>. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
What does this PR do?
Based on feedback in FB there are some flaws regarding the install scripts and documentation. This PR will address that.
Overview
This PR significantly enhances the reliability, cross-platform compatibility, and user experience of the Rig Bridge installation and update logic. The installer scripts across Windows, macOS, and Linux have been structurally refactored to securely handle dynamic configurations, safely flush out stale code bases during updates, and aggressively guarantee users are surfaced with the proper documentation requirements before booting the Setup UI.
Target Branch:
stagingInstaller Logic Enhancements
server/routes/rig-bridge.js) no longer rely onlocalhost:5555. Everything is now explicitly extracted straight out of therig-bridge-config.jsonfile. It dynamically loads theport,tlsprotocols, and custombindAddressIPs to properly formulate networking connections.5555.rmdir /S /Qon Windows andfind -mindepth 1 -maxdepth 1 ... -exec rm -rf {} +on Mac/Linux) prior to cloning the updated Git repository.rig-bridge/README.md, and completely automatically open the browser directly afterwards.Documentation Updates
rig-bridge/README.mdeffectively clarifying the new automatic installer UI-prompting behavior.Related Issues/Files Changed
server/routes/rig-bridge.jsrig-bridge/README.mdVerification
.bat/.sh) behavior locally to confirm parent variables are rigorously structured against expansion/recursion threats.