install.sh: every line fits 80 columns; the closing card is a tidy table

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-09-19 11:13:27 -07:00
co-authored by Claude Fable 5.1
parent 3c0c504e35
commit d9470bbfe1
+24 -23
View File
@@ -158,8 +158,8 @@ existing=$(command -v hamlab 2>/dev/null || true); [ -n "$existing" ] || { [ -x
have=; [ -z "$existing" ] || have=$("$existing" version 2>/dev/null | awk '{ print $2 }') || true
good "$os ${D}${DOT}${R} $(uname -m) ${D}${DOT}${R} $init"
case "$how" in root) good "running as root" ;; *) good "running as ${B}$me${R}; $how will ask for root when it is needed" ;; esac
[ "$init" != none ] || warn "no systemd or OpenRC here: Ham Lab will be installed, but nothing will start it at boot"
case "$how" in root) good "running as root" ;; *) good "running as ${B}$me${R}; $how is asked for root when it is needed" ;; esac
[ "$init" != none ] || warn "no systemd or OpenRC: it will be installed, but nothing starts it at boot"
# ───────────────────────────────────────────────────── which version ──
tmp=$(mktemp -d 2>/dev/null || mktemp -d -t hamlab)
@@ -177,8 +177,8 @@ else
ver=$(fetch "$HAMLAB_URL/VERSION" "$tmp/VERSION" 2>/dev/null && head -n 1 "$tmp/VERSION" | tr -cd 'A-Za-z0-9._+-' || true)
[ -n "$ver" ] || { ver=$BUILT_FOR; case "$ver" in @*) ver=latest ;; esac; }
fi
if [ -n "$have" ] && [ "$have" = "$ver" ]; then good "Ham Lab ${B}$have${R} is already installed here ${D}${ARROW}${R} this will reinstall it, keeping its config, user and password"
elif [ -n "$have" ]; then good "Ham Lab ${B}$have${R} is installed here ${D}${ARROW}${R} this will upgrade it to ${B}$ver${R}, keeping its config, user and password"
if [ -n "$have" ] && [ "$have" = "$ver" ]; then good "Ham Lab ${B}$have${R} is already installed ${D}${ARROW}${R} this reinstalls it"; note " its config, user and password are kept"
elif [ -n "$have" ]; then good "Ham Lab ${B}$have${R} is installed ${D}${ARROW}${R} upgrading to ${B}$ver${R}"; note " its config, user and password are kept"
else good "installing Ham Lab ${B}$ver${R}"; fi
# ─────────────────────────────────────────────────────────── the wizard ──
@@ -189,7 +189,7 @@ if [ "$INTERACTIVE" = 1 ] && [ -n "$have" ]; then
elif [ "$INTERACTIVE" = 1 ]; then
# 1 ─ who
default_user=${SUDO_USER:-${DOAS_USER:-$me}}
step "1/5" "Who should it run as?" "Its terminals are that user's login shell, and its files are that user's files."
step "1/5" "Who should it run as?" "Its terminals are that user's shell; its files are that user's files."
while :; do
ask "User" "$default_user"; run_as=$REPLY
id "$run_as" >/dev/null 2>&1 && break
@@ -198,13 +198,13 @@ elif [ "$INTERACTIVE" = 1 ]; then
[ "$run_as" != root ] || warn "as root, every terminal it opens is a root shell"
# 2 ─ where
step "2/5" "Where should it listen?" "Who can reach the console at all. The password still guards it either way."
step "2/5" "Where should it listen?" "Who can reach the console at all. The password guards it either way."
addrs=$(lan_addresses || true); first=$(printf '%s\n' "$addrs" | awk 'NR == 1 { print $1 }')
if [ -n "$first" ]; then
first_if=$(printf '%s\n' "$addrs" | awk 'NR == 1 { print $2 }')
choose 2 "This machine only ${D}127.0.0.1 — reach it over an SSH tunnel or a reverse proxy${R}" \
"This network ${D}$first on $first_if — other machines on the LAN can open it${R}" \
"Every interface ${D}0.0.0.0 — all addresses this machine has or gets${R}" \
choose 2 "This machine only ${D}127.0.0.1 — for an SSH tunnel or a reverse proxy${R}" \
"This network ${D}$first ($first_if) — reachable from the LAN${R}" \
"Every interface ${D}0.0.0.0 — every address it has or gets${R}" \
"Another address"
else
choose 1 "This machine only ${D}127.0.0.1${R}" "Every interface ${D}0.0.0.0${R}" "Another address"
@@ -228,11 +228,11 @@ elif [ "$INTERACTIVE" = 1 ]; then
case "$host" in *:*) listen="[$host]:$port" ;; *) listen="$host:$port" ;; esac
# 3 ─ https
step "3/5" "HTTPS?" "A self-signed certificate is made here; browsers warn once, a hub pins its fingerprint."
step "3/5" "HTTPS?" "With a certificate made here: browsers warn once, a hub pins it."
if [ "$host" = 127.0.0.1 ]; then
choose 2 "HTTPS with a self-signed certificate" "Plain HTTP ${D}— fine here: nothing leaves this machine unencrypted${R}"
choose 2 "HTTPS, self-signed" "Plain HTTP ${D}— fine here: nothing leaves this machine${R}"
else
choose 1 "HTTPS with a self-signed certificate ${D}— recommended: the password crosses the network${R}" "Plain HTTP ${D}— only behind a reverse proxy that adds HTTPS itself${R}"
choose 1 "HTTPS, self-signed ${D}— recommended: the password crosses the network${R}" "Plain HTTP ${D}— only behind a reverse proxy that adds HTTPS${R}"
fi
if [ "$REPLY" = 1 ]; then tls=auto; scheme=https; else tls=off; scheme=http; fi
@@ -254,7 +254,7 @@ elif [ "$INTERACTIVE" = 1 ]; then
fi
# 5 ─ password
step "5/5" "The password" "One password opens the console — and the console is a shell on this machine."
step "5/5" "The password" "One password opens the console, and the console is a shell here."
choose 1 "Choose one now" "Generate a strong one ${D}— shown once at the end${R}"
if [ "$REPLY" = 1 ]; then
while :; do
@@ -302,7 +302,7 @@ if [ -f "$tmp/SHA256SUMS" ] && command -v sha256sum >/dev/null 2>&1; then
want=$(awk -v f="$file" '$2 == f || $2 == "*" f { print $1 }' "$tmp/SHA256SUMS")
got=$(sha256sum "$tmp/hamlab" | awk '{ print $1 }')
[ -n "$want" ] || die "SHA256SUMS has no entry for $file."
[ "$want" = "$got" ] || die "Checksum mismatch for $file — the download is not what was published. Nothing was installed."
[ "$want" = "$got" ] || die "Checksum mismatch for $file: this is not the file that was published. Nothing was installed."
good "checksum matches SHA256SUMS"
else
warn "no SHA256SUMS (or no sha256sum here): the download was not verified"
@@ -342,19 +342,20 @@ hamlab_bin=$(command -v hamlab 2>/dev/null || echo /usr/local/bin/hamlab)
blank; rule
out " ${GREEN}${B}${OK} Ham Lab $("$hamlab_bin" version 2>/dev/null | awk '{ print $2 }') is installed${R}"
blank
row() { out " $(printf '%-10s' "$1") $2"; [ -z "${3:-}" ] || out " ${D}$3${R}"; }
if [ "$init" = none ]; then
out " start it ${B}hamlab serve${R} ${D}as $([ -n "${run_as:-}" ] && echo "$run_as" || echo "its user") — nothing here starts it at boot, so put that under your supervisor${R}"
row "start it" "${B}hamlab serve${R}" "as ${run_as:-its user}, under your own supervisor: nothing here starts it at boot"
fi
if [ -n "$listen" ]; then
out " open ${CYAN}${B}$scheme://$(printf '%s' "$listen" | sed "s/^0\.0\.0\.0/$url_host/")${R}"
[ "$tls" != auto ] || out " ${D}your browser will warn about the self-signed certificate once; that is expected${R}"
[ "$host" != 127.0.0.1 ] || out " ${D}from another machine: ssh -L $port:127.0.0.1:$port $run_as@<this machine>, then http://127.0.0.1:$port${R}"
row "open" "${CYAN}${B}$scheme://$(printf '%s' "$listen" | sed "s/^0\.0\.0\.0/$url_host/")${R}"
[ "$tls" != auto ] || out " ${D}the browser warns about the self-signed certificate once${R}"
[ "$host" != 127.0.0.1 ] || out " ${D}from elsewhere: ssh -L $port:127.0.0.1:$port $run_as@this-machine${R}"
fi
out " manage ${B}hamlab install --help${R} ${D}change the address, HTTPS, the user — it keeps everything else${R}"
case "$init" in
systemd) out " logs ${B}journalctl -u hamlab -f${R}" ;;
OpenRC) out " logs ${B}tail -f /var/log/hamlab.log${R}" ;;
systemd) row "logs" "${B}journalctl -u hamlab -f${R}" ;;
OpenRC) row "logs" "${B}tail -f /var/log/hamlab.log${R}" ;;
esac
out " add to hub ${D}on your main Ham Lab: Machines ${ARROW} Add a machine, with this address and password${R}"
out " remove ${B}hamlab uninstall${R} ${D}(--purge deletes its config too)${R}"
row "change" "${B}hamlab install --help${R}" "a new address, HTTPS or user; everything else is kept"
row "add to hub" "Machines ${ARROW} Add a machine" "on your main Ham Lab, with this address and password"
row "remove" "${B}hamlab uninstall${R}" "--purge deletes its config too"
rule; blank