`inbuxa` with no arguments (or `inbuxa install` with no options) opens the installer spec's interface in the terminal: what it found on this machine, the names, which components go here and how, what answers on 80 and 443, the whole plan, and the install. It fills in the same plan.Options the flags do, builds the plan with plan.Build and installs with apply.Run: it is a way of choosing, not a second installer. The plan screen shows the command that does the same without it, and nothing happens until a "y". - Components: what the machine can't do is greyed out with the reason beside it; what it lacks and the installer can add (docker, compose) is offered and added, with --install-deps in the command. The defaults are the flags' defaults. Front ends without a server here point to join. - Reach offers Caddy or your own web server. --proxy snippets is left out: the plan describes it, but nothing writes those files yet (now said in the README). - The install screen ticks off apply's steps with its output underneath, asks before stopping a running install, and ends on the credentials and addresses, printed again once the terminal is given back. - Without root it refuses at the plan, saying why. Without a terminal it says which flags do the same, exit 2. A window under 60x16 says so. The terminal layer is ours and the standard library's (installer spec §8, decision 1): raw mode, size and SIGWINCH through syscall, key decoding, full redraws, NO_COLOR honored, the terminal restored on every way out. Also: the survey's text moved to plan.SurveyText, which the first screen and `inbuxa survey` share; and plan.Available now says host installs of the console and the webmail aren't built, so --console host is refused at the plan instead of after it. Tests: key decoding, fitting and wrapping, and the wizard driven by keys against an installer that changes nothing (defaults, loopback, the server on the host, refusals, root and the y, stopping, a machine without docker, a small window), under -race. e2e/cases/interface.sh drives the binary in a pseudo-terminal on a fresh Debian 13 lab through a whole loopback install: 22/22. install-local, install-host, install-public, status-export and topology pass unchanged.
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
// SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
//go:build linux
|
|
|
|
package tui
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// rawMode puts the terminal into raw mode -- keys arrive one at a time, not
|
|
// echoed, with no line editing and no signals from Ctrl-C -- and returns how
|
|
// to put it back. Nothing else in the program touches termios.
|
|
func rawMode(f *os.File) (restore func(), err error) {
|
|
fd := f.Fd()
|
|
var old syscall.Termios
|
|
if _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCGETS, uintptr(unsafe.Pointer(&old))); e != 0 {
|
|
return nil, e
|
|
}
|
|
raw := old
|
|
raw.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP |
|
|
syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
|
|
raw.Oflag &^= syscall.OPOST
|
|
raw.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
|
|
raw.Cflag &^= syscall.CSIZE | syscall.PARENB
|
|
raw.Cflag |= syscall.CS8
|
|
raw.Cc[syscall.VMIN] = 1
|
|
raw.Cc[syscall.VTIME] = 0
|
|
if _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCSETS, uintptr(unsafe.Pointer(&raw))); e != 0 {
|
|
return nil, e
|
|
}
|
|
return func() {
|
|
syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TCSETS, uintptr(unsafe.Pointer(&old)))
|
|
}, nil
|
|
}
|
|
|
|
// size is the terminal's width and height in cells.
|
|
func size(f *os.File) (w, h int) {
|
|
var ws struct{ Row, Col, X, Y uint16 }
|
|
if _, _, e := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws))); e != 0 || ws.Col == 0 {
|
|
return 80, 24
|
|
}
|
|
return int(ws.Col), int(ws.Row)
|
|
}
|
|
|
|
// IsTerminal is whether f is a terminal at all, which is what decides between
|
|
// the interface and a sentence about the flags.
|
|
func IsTerminal(f *os.File) bool {
|
|
var t syscall.Termios
|
|
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), syscall.TCGETS, uintptr(unsafe.Pointer(&t)))
|
|
return e == 0
|
|
}
|
|
|
|
// resizeSignal is the signal a terminal sends when its window changes size.
|
|
var resizeSignal os.Signal = syscall.SIGWINCH
|