v0.5.3: fix installer require_tty before tee redirect

QEMU boot test of v0.5.2 found service still status=1/FAILURE despite
file present at /usr/local/bin/veilor-installer. Root cause via
`bash -x`: `exec > >(tee -a "$LOG") 2>&1` ran BEFORE require_tty
check; process substitution replaces fd1 with a pipe, so [[ -t 1 ]]
returns false → require_tty bails out with [ERR] message.

Order was self-inflicted bug from v0.5.0. Fix: move require_tty
function definition + call BEFORE the tee redirect. Drop the
redundant require_tty call in the entry block (would fail post-redirect).
This commit is contained in:
veilor-org 2026-05-02 06:22:47 +01:00
parent ada76caa1f
commit 55b57c224e

View file

@ -18,6 +18,18 @@
set -uo pipefail set -uo pipefail
export TERM="${TERM:-linux}" export TERM="${TERM:-linux}"
LOG=/var/log/veilor-installer.log LOG=/var/log/veilor-installer.log
# require_tty MUST run before the tee redirect — process substitution
# replaces fd1 with a pipe, breaking `[[ -t 1 ]]`.
require_tty() {
if ! [[ -t 0 && -t 1 ]]; then
echo "[ERR] veilor-installer must run on a real tty" >&2
exit 1
fi
}
require_tty
# Now safe to tee output for log persistence — tty detection already passed.
exec > >(tee -a "$LOG") 2>&1 exec > >(tee -a "$LOG") 2>&1
# ── Branded styling for gum ───────────────────────────────────────────── # ── Branded styling for gum ─────────────────────────────────────────────
@ -64,13 +76,6 @@ EOF
fi fi
} }
require_tty() {
if ! [[ -t 0 && -t 1 ]]; then
echo "[ERR] veilor-installer must run on a real tty" >&2
exit 1
fi
}
# ── TUI wrapper functions ─────────────────────────────────────────────── # ── TUI wrapper functions ───────────────────────────────────────────────
# Each prompt_* call abstracts gum / whiptail. Always emit the chosen value # Each prompt_* call abstracts gum / whiptail. Always emit the chosen value
# on stdout; non-zero exit on cancel/ESC. Callers use `||` to propagate. # on stdout; non-zero exit on cancel/ESC. Callers use `||` to propagate.
@ -562,7 +567,7 @@ launch_desktop() {
} }
# ── Entry ── # ── Entry ──
require_tty # (require_tty already called above before exec redirect — see top of file)
banner banner
while true; do while true; do