fix: patch setup.sh env.list sed lines to be non-fatal, kill port with ss

This commit is contained in:
admin 2026-08-01 18:36:11 +00:00
parent bc66018af3
commit 0922102226

View file

@ -61,17 +61,15 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
return fmt.Errorf("extract: %w\n%s", err, string(out))
}
// Run setup.sh with env.list protection
fmt.Printf("[%s] Running setup...\n", node.Name)
// 5. Patch setup.sh: make env.list sed commands non-fatal (file gets deleted during nginx test)
setupPath := filepath.Join(DeployTo, "setup.sh")
// Wrapper: ensure env.list exists before any sed commands touch it
wrapper := fmt.Sprintf(`#!/bin/bash
trap 'touch %s/env.list 2>/dev/null' DEBUG
bash %s "$@"
`, DeployTo, setupPath)
wrapperPath := filepath.Join(DeployTo, "run-setup.sh")
os.WriteFile(wrapperPath, []byte(wrapper), 0755)
cmd = exec.Command("bash", wrapperPath,
exec.Command("sed", "-i",
`s|\(/opt/wallarm/env.list\)|\1 2>/dev/null || true|g`,
setupPath).Run()
// 6. Run setup.sh
fmt.Printf("[%s] Running setup...\n", node.Name)
cmd = exec.Command("bash", setupPath,
"--batch", "--token", apiToken, "--cloud", cloudFromHost(apiHost),
"--custom-ngx-build",
)