fix: try all package managers for NGINX, clear error if all fail
This commit is contained in:
parent
f299f7f895
commit
0ac2fc82cf
1 changed files with 25 additions and 2 deletions
|
|
@ -235,13 +235,36 @@ func CreateNodesDir() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// installNginx ensures NGINX is present on the system.
|
// installNginx ensures NGINX is present on the system.
|
||||||
|
// Tries apt, yum, dnf, apk — prints clear error if all fail.
|
||||||
func installNginx() {
|
func installNginx() {
|
||||||
if _, err := exec.LookPath("nginx"); err == nil {
|
if _, err := exec.LookPath("nginx"); err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("Installing NGINX (required by Wallarm node)...")
|
fmt.Println("Installing NGINX (required by Wallarm node)...")
|
||||||
exec.Command("apt-get", "update", "-qq").Run()
|
|
||||||
exec.Command("apt-get", "install", "-y", "-qq", "nginx").Run()
|
// Try common package managers
|
||||||
|
for _, pm := range [][]string{
|
||||||
|
{"apt-get", "update", "-qq"},
|
||||||
|
{"apt-get", "install", "-y", "-qq", "nginx"},
|
||||||
|
{"yum", "install", "-y", "-q", "nginx"},
|
||||||
|
{"dnf", "install", "-y", "-q", "nginx"},
|
||||||
|
{"apk", "add", "--no-cache", "nginx"},
|
||||||
|
} {
|
||||||
|
if _, err := exec.LookPath(pm[0]); err == nil {
|
||||||
|
cmd := exec.Command(pm[0], pm[1:]...)
|
||||||
|
if out, err := cmd.CombinedOutput(); err == nil {
|
||||||
|
fmt.Println(" Installed via", pm[0])
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
_ = out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all fail, print instructions
|
||||||
|
fmt.Println("Could not install NGINX automatically.")
|
||||||
|
fmt.Println("Install it manually: apt-get install nginx")
|
||||||
|
fmt.Println("Then re-run the deployment.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloudFromHost maps API host to cloud region code (US/EU/ME).
|
// cloudFromHost maps API host to cloud region code (US/EU/ME).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue