fix: trap DEBUG to ensure env.list always exists during setup.sh

This commit is contained in:
admin 2026-08-01 18:27:20 +00:00
parent 8638f198ff
commit 4432855a2d

View file

@ -56,9 +56,17 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
return fmt.Errorf("extract: %w\n%s", err, string(out)) return fmt.Errorf("extract: %w\n%s", err, string(out))
} }
// 5. Run setup.sh natively // Run setup.sh with env.list protection
fmt.Printf("[%s] Running setup...\n", node.Name) fmt.Printf("[%s] Running setup...\n", node.Name)
cmd = exec.Command("bash", filepath.Join(DeployTo, "setup.sh"), 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,
"--batch", "--token", apiToken, "--cloud", cloudFromHost(apiHost), "--batch", "--token", apiToken, "--cloud", cloudFromHost(apiHost),
"--custom-ngx-build", "--custom-ngx-build",
) )