mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-22 12:16:52 +00:00
7c007ea6b5
Replaces charmbracelet/huh with a custom bubbletea wizard for the installer TUI. This gives full control over terminal I/O so the installer attaches directly to the correct console device (ttyS0 for serial, tty1 for VGA) as directed by the new spinifex-init boot script. - branding/branding.go: centralised logo (ASCII placeholder), color constants, and publisher string ready for Mulga asset swap - ui/ui.go: multi-screen bubbletea model (welcome → disk → network → identity → join → CA cert → confirm) styled with lipgloss - main.go: reads SPINIFEX_CONSOLE from /proc/cmdline to open the right tty before launching tea.Program - go.mod: bubbletea/lipgloss/bubbles promoted to direct deps; huh removed
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
/*
|
|
Copyright © 2026 Mulga Defense Corporation
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/mulgadc/spinifex/cmd/installer/install"
|
|
"github.com/mulgadc/spinifex/cmd/installer/ui"
|
|
)
|
|
|
|
func main() {
|
|
ttyPath := detectTTY()
|
|
|
|
cfg, err := ui.Run(ttyPath)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "installer: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err := install.Run(cfg); err != nil {
|
|
fmt.Fprintf(os.Stderr, "install failed: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// detectTTY returns the TTY device path the installer should attach to.
|
|
// It reads SPINIFEX_CONSOLE from the kernel cmdline (/proc/cmdline) so that
|
|
// spinifex-init can direct the installer to the correct console (ttyS0 for
|
|
// serial, tty1 for VGA). Falls back to tty1.
|
|
func detectTTY() string {
|
|
data, err := os.ReadFile("/proc/cmdline")
|
|
if err == nil {
|
|
for param := range strings.FieldsSeq(string(data)) {
|
|
if after, ok := strings.CutPrefix(param, "SPINIFEX_CONSOLE="); ok {
|
|
val := after
|
|
if val != "" && val != "auto" {
|
|
return "/dev/" + val
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return "/dev/tty1"
|
|
}
|