fix: extract Makeself archive with --noexec, then run setup.sh
- Uses Makeself --noexec --target to extract without running - Then runs the embedded setup.sh with WALLARM_API_TOKEN and WALLARM_API_HOST env vars - Interactive prompts handled via stdin pipe
This commit is contained in:
parent
b1c596ccf2
commit
f5919b4c85
1 changed files with 23 additions and 10 deletions
|
|
@ -88,26 +88,39 @@ WALLARM_CONFIG_PATH=%s
|
|||
return fmt.Errorf("write env: %w", err)
|
||||
}
|
||||
|
||||
// 5. Run the meganode installer (piped token + region to avoid interactive prompts)
|
||||
fmt.Printf("[%s] Running Wallarm installer...\n", node.Name)
|
||||
installCmd := exec.Command(installerPath)
|
||||
installCmd.Dir = workDir
|
||||
installCmd.Env = append(os.Environ(),
|
||||
// 5. Extract the Makeself archive (--noexec skips running setup.sh)
|
||||
fmt.Printf("[%s] Extracting installer...\n", node.Name)
|
||||
extractCmd := exec.Command("bash", installerPath, "--noexec", "--target", workDir, "--noprogress", "--accept")
|
||||
extractCmd.Dir = workDir
|
||||
if out, err := extractCmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("extract installer: %w\n%s", err, string(out))
|
||||
}
|
||||
|
||||
// 6. Run the embedded setup.sh with our configuration
|
||||
setupScript := filepath.Join(workDir, "setup.sh")
|
||||
if _, err := os.Stat(setupScript); err != nil {
|
||||
return fmt.Errorf("setup.sh not found after extraction: %w", err)
|
||||
}
|
||||
fmt.Printf("[%s] Running setup...\n", node.Name)
|
||||
setupCmd := exec.Command("bash", setupScript)
|
||||
setupCmd.Dir = workDir
|
||||
setupCmd.Env = append(os.Environ(),
|
||||
"WALLARM_API_TOKEN="+apiToken,
|
||||
"WALLARM_API_HOST="+apiHost,
|
||||
"WALLARM_LABELS="+labels,
|
||||
"WALLARM_ACCEPT_EULA=true",
|
||||
)
|
||||
// Pipe token and region as stdin to skip interactive prompts
|
||||
installCmd.Stdin = strings.NewReader(apiToken + "\n" + apiHost + "\n")
|
||||
// Pipe token + host to handle interactive prompts
|
||||
setupCmd.Stdin = strings.NewReader(apiToken + "\n" + apiHost + "\n")
|
||||
|
||||
logFile, err := os.Create(filepath.Join(workDir, "install.log"))
|
||||
if err == nil {
|
||||
installCmd.Stdout = logFile
|
||||
installCmd.Stderr = logFile
|
||||
setupCmd.Stdout = logFile
|
||||
setupCmd.Stderr = logFile
|
||||
defer logFile.Close()
|
||||
}
|
||||
|
||||
if err := installCmd.Run(); err != nil {
|
||||
if err := setupCmd.Run(); err != nil {
|
||||
return fmt.Errorf("installation failed — check %s/install.log: %w", workDir, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue