feat(setup): add web-based first-run configuration wizard

When config.json is missing, Erupe now launches a temporary HTTP server
on port 8080 serving a guided setup wizard instead of exiting with a
cryptic error. The wizard walks users through database connection,
schema initialization (pg_restore + SQL migrations), and server settings,
then writes config.json and continues normal startup without restart.
This commit is contained in:
Houmgaor
2026-02-23 20:55:56 +01:00
parent 085dc57648
commit 6a7db47723
7 changed files with 1368 additions and 5 deletions

18
main.go
View File

@@ -16,6 +16,7 @@ import (
"erupe-ce/server/channelserver"
"erupe-ce/server/discordbot"
"erupe-ce/server/entranceserver"
"erupe-ce/server/setup"
"erupe-ce/server/signserver"
"strings"
@@ -79,11 +80,18 @@ func main() {
config, cfgErr := cfg.LoadConfig()
if cfgErr != nil {
fmt.Println("\nFailed to start Erupe:\n" + fmt.Sprintf("Failed to load config: %s", cfgErr.Error()))
go wait()
fmt.Println("\nPress Enter/Return to exit...")
_, _ = fmt.Scanln()
os.Exit(0)
if _, err := os.Stat("config.json"); os.IsNotExist(err) {
logger.Info("No config.json found, launching setup wizard")
if err := setup.Run(logger.Named("setup"), 8080); err != nil {
logger.Fatal("Setup wizard failed", zap.Error(err))
}
config, cfgErr = cfg.LoadConfig()
if cfgErr != nil {
logger.Fatal("Config still invalid after setup", zap.Error(cfgErr))
}
} else {
preventClose(config, fmt.Sprintf("Failed to load config: %s", cfgErr.Error()))
}
}
logger.Info(fmt.Sprintf("Starting Erupe (9.3b-%s)", Commit()))