From bb4fd3e11c76a82a7fc7f57ce398f1305ebbd17f Mon Sep 17 00:00:00 2001 From: Greg Reed Date: Sun, 8 Nov 2026 01:39:57 +0000 Subject: [PATCH] fix(boot-test): fill {PUBLIC_*} in the startup command like the panel does Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MZxvxViV6QwAtVWT3saGvs --- cmd/gbrgames/boottest.go | 9 ++++++++- cmd/gbrgames/boottest_test.go | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cmd/gbrgames/boottest.go b/cmd/gbrgames/boottest.go index 22662ff..297e01d 100644 --- a/cmd/gbrgames/boottest.go +++ b/cmd/gbrgames/boottest.go @@ -153,6 +153,13 @@ func bootTestPayload(gamesDir, id string, fillBlank bool) (map[string]any, error } } + // The panel fills {PUBLIC_IP}, {PUBLIC_HOST} and {PUBLIC_PORT_n} in the startup command too + startup := g["defaultStartupCommand"] + if cmd, ok := startup.(string); ok { + cmd = strings.NewReplacer("{PUBLIC_IP}", "127.0.0.1", "{PUBLIC_HOST}", "127.0.0.1").Replace(cmd) + startup = publicPort.ReplaceAllString(cmd, "$1") + } + return map[string]any{ "command": "DEPLOY_SERVER", "serverId": "boottest-" + id, @@ -166,7 +173,7 @@ func bootTestPayload(gamesDir, id string, fillBlank bool) (map[string]any, error "configFilePath": g["configFilePath"], "configFileFormat": g["configFileFormat"], "configFormatOptions": g["configFormatOptions"], - "startupCommand": g["defaultStartupCommand"], + "startupCommand": startup, "memoryLimitMb": g["requiredMemoryMb"], "containerUser": g["containerUser"], "dockerNetwork": bootTestNetwork, diff --git a/cmd/gbrgames/boottest_test.go b/cmd/gbrgames/boottest_test.go index 0d1f4ac..1f287b8 100644 --- a/cmd/gbrgames/boottest_test.go +++ b/cmd/gbrgames/boottest_test.go @@ -132,3 +132,18 @@ func TestSteamCacheStampAge(t *testing.T) { t.Error("old, missing or garbled stamps are not fresh") } } + +func TestBootTestPayloadFillsPublicPlaceholdersInStartupCommand(t *testing.T) { + dir := t.TempDir() + game := filepath.Join(dir, "example") + os.MkdirAll(game, 0o755) + os.WriteFile(filepath.Join(game, "game.yaml"), []byte("id: example\nname: Example\ndefaultDockerImage: x\n"+ + "defaultStartupCommand: ./server -Port={PUBLIC_PORT_7777} -ip={PUBLIC_IP}\ndefaultPorts:\n - 7777/udp\n"), 0o644) + p, err := bootTestPayload(dir, "example", false) + if err != nil { + t.Fatal(err) + } + if p["startupCommand"] != "./server -Port=7777 -ip=127.0.0.1" { + t.Errorf("startupCommand %v", p["startupCommand"]) + } +}