diff --git a/internal/native/native.go b/internal/native/native.go index f229f51..9de8073 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -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) }