From 8b49978ea1bd86b6505be2f06f27b2b9e0108ae8 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 1 Aug 2026 21:52:36 +0000 Subject: [PATCH] fix: use bundled python3.10 in systemd, patch paths after move --- internal/native/native.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/native/native.go b/internal/native/native.go index 9fc81ae..e8a2f3a 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -138,6 +138,9 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error { os.RemoveAll(instanceDir) os.Rename(DeployTo, instanceDir) + // 8. Patch hardcoded /opt/wallarm paths + patchPaths(instanceDir) + // 9. Set up systemd service GenerateSystemdTemplate() svc := "wallarm-node@" + node.Name @@ -182,25 +185,23 @@ func CreateNodesDir() error { return os.MkdirAll(BaseDir, 0755) } func GenerateSystemdTemplate() error { tmpl := `/etc/systemd/system/wallarm-node@.service` - if _, err := os.Stat(tmpl); err == nil { - return nil // already exists - } content := fmt.Sprintf(`[Unit] Description=Wallarm Node - %%i After=network.target [Service] -Type=forking +Type=simple WorkingDirectory=%s/%%i/wallarm -ExecStart=/bin/bash %s/%%i/wallarm/supervisord.sh start -ExecStop=/bin/bash %s/%%i/wallarm/supervisord.sh stop +EnvironmentFile=-%s/%%i/wallarm/env.list +ExecStart=%s/%%i/wallarm/usr/bin/python3.10 %s/%%i/wallarm/usr/bin/supervisord -c %s/%%i/wallarm/etc/supervisord.conf +ExecStop=%s/%%i/wallarm/usr/bin/python3.10 %s/%%i/wallarm/usr/bin/supervisord -c %s/%%i/wallarm/etc/supervisord.conf shutdown Restart=on-failure RestartSec=5 User=root [Install] WantedBy=multi-user.target -`, BaseDir, BaseDir, BaseDir) +`, BaseDir, BaseDir, BaseDir, BaseDir, BaseDir, BaseDir, BaseDir, BaseDir) os.WriteFile(tmpl, []byte(content), 0644) exec.Command("systemctl", "daemon-reload").Run() return nil @@ -255,3 +256,12 @@ func killPort(port string) { fmt.Printf(" Killed existing process on port %s\n", port) } } + +func patchPaths(dir string) { + exec.Command("sed", "-i", fmt.Sprintf("s|/opt/wallarm|%s|g", dir), + filepath.Join(dir, "env.list")).Run() + exec.Command("find", dir, "-name", "*.sh", "-exec", + "sed", "-i", fmt.Sprintf("s|/opt/wallarm|%s|g", dir), "{}", ";").Run() + exec.Command("sed", "-i", fmt.Sprintf("s|/opt/wallarm|%s|g", dir), + filepath.Join(dir, "etc", "supervisord.conf")).Run() +}