`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.
102 lines
2.8 KiB
Go
102 lines
2.8 KiB
Go
// SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package plan
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.coffeylabs.org/inbuxa/inbuxa-installer/internal/host"
|
|
)
|
|
|
|
// SurveyText is the first screen, as text: what this machine is, and what that
|
|
// allows. Every line is something a later choice depends on.
|
|
func SurveyText(f host.Facts) string {
|
|
var b strings.Builder
|
|
b.WriteString("This machine\n")
|
|
os_ := f.OS.Pretty
|
|
if os_ == "" {
|
|
os_ = "an unrecognized Linux"
|
|
}
|
|
fmt.Fprintf(&b, " %-22s %s\n", "system", os_)
|
|
fmt.Fprintf(&b, " %-22s %s\n", "init", yes(f.Systemd, "systemd", "not systemd -- host installs are unavailable"))
|
|
fmt.Fprintf(&b, " %-22s %s\n", "running as", yes(f.Root, "root", "an ordinary user -- installing will fail"))
|
|
if f.MemoryMB > 0 {
|
|
fmt.Fprintf(&b, " %-22s %d MB\n", "memory", f.MemoryMB)
|
|
}
|
|
if f.DiskFreeGB > 0 {
|
|
fmt.Fprintf(&b, " %-22s %d GB free\n", "disk", f.DiskFreeGB)
|
|
}
|
|
|
|
runtime := "none: neither docker nor podman is installed"
|
|
switch {
|
|
case f.Runtime.Usable:
|
|
runtime = f.Runtime.Kind + " " + f.Runtime.Version + ", compose " + f.Runtime.Compose
|
|
if f.Runtime.Socket != "" {
|
|
runtime += ", at " + f.Runtime.Socket
|
|
}
|
|
case f.Runtime.Present:
|
|
runtime = f.Runtime.Kind + " installed but not usable: " + f.Runtime.Why
|
|
}
|
|
fmt.Fprintf(&b, " %-22s %s\n", "container runtime", runtime)
|
|
|
|
glibc := "could not be read"
|
|
if f.Glibc.Version != "" {
|
|
glibc = f.Glibc.Version
|
|
if !f.Glibc.AtLeast(ServerGlibcMajor, ServerGlibcMinor) {
|
|
glibc += fmt.Sprintf(" (older than the %d.%d the server binary needs)", ServerGlibcMajor, ServerGlibcMinor)
|
|
}
|
|
}
|
|
fmt.Fprintf(&b, " %-22s %s\n", "glibc", glibc)
|
|
|
|
node := "not installed"
|
|
switch {
|
|
case f.Node.Present && f.Node.Major >= 22:
|
|
node = f.Node.Version + " at " + f.Node.Path
|
|
case f.Node.Present:
|
|
node = f.Node.Version + " (too old for a host install of the webmail)"
|
|
}
|
|
fmt.Fprintf(&b, " %-22s %s\n", "node", node)
|
|
if f.Existing != "" {
|
|
fmt.Fprintf(&b, " %-22s %s\n", "existing install", f.Existing)
|
|
}
|
|
|
|
b.WriteString("\nPorts\n")
|
|
for _, p := range f.Ports {
|
|
state := "free"
|
|
switch {
|
|
case p.Free:
|
|
case p.Unknown:
|
|
state = "cannot tell without root"
|
|
default:
|
|
state = "held"
|
|
if p.Holder != "" {
|
|
state += " by " + p.Holder
|
|
}
|
|
}
|
|
fmt.Fprintf(&b, " %-6d %-42s %s\n", p.Number, p.For, state)
|
|
}
|
|
|
|
b.WriteString("\nWhat this machine allows\n")
|
|
for _, c := range []Component{Server, Console, Webmail} {
|
|
var shapes []string
|
|
for _, s := range []Shape{Container, Host} {
|
|
if a := Available(f, c, s); a.OK {
|
|
shapes = append(shapes, string(s))
|
|
} else {
|
|
shapes = append(shapes, fmt.Sprintf("%s (no: %s)", s, a.Why))
|
|
}
|
|
}
|
|
fmt.Fprintf(&b, " %-10s %s\n", c, strings.Join(shapes, " "))
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
func yes(b bool, t, f string) string {
|
|
if b {
|
|
return t
|
|
}
|
|
return f
|
|
}
|