fix: preflight URL, /opt/fw/ refactor complete
This commit is contained in:
parent
02f3368fa6
commit
b44da10ae7
5 changed files with 33 additions and 30 deletions
|
|
@ -125,8 +125,8 @@ func runDeployFlow(r preflight.Result) {
|
|||
return
|
||||
}
|
||||
|
||||
baseDir := "/opt/wallarm"
|
||||
instanceDir := baseDir + "/" + nodeName
|
||||
baseDir := "/opt/fw"
|
||||
instanceDir := baseDir + "/" + nodeName + "/wallarm"
|
||||
|
||||
portNum, _ := strconv.Atoi(upstreamPort)
|
||||
s.Nodes = append(s.Nodes, state.Node{
|
||||
|
|
@ -181,11 +181,11 @@ WALLARM_REGION=%s
|
|||
fmt.Println()
|
||||
fmt.Println("✅ Deployment complete!")
|
||||
fmt.Println()
|
||||
fmt.Printf(" Binary: /opt/wallarm/deploy\n")
|
||||
fmt.Printf(" Binary: /opt/fw/deploy\n")
|
||||
fmt.Printf(" Instance: %s\n", instanceDir)
|
||||
fmt.Printf(" State: /opt/wallarm/state.json\n")
|
||||
fmt.Printf(" State: /opt/fw/state.json\n")
|
||||
fmt.Println()
|
||||
fmt.Println("Run 'sudo /opt/wallarm/deploy' for the dashboard.")
|
||||
fmt.Println("Run 'sudo /opt/fw/deploy' for the dashboard.")
|
||||
}
|
||||
func runTunnelFlow() {
|
||||
fmt.Println()
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
BaseDir = "/opt/wallarm"
|
||||
NodesDir = BaseDir + "/nodes"
|
||||
NginxDir = BaseDir + "/nginx"
|
||||
SystemdTemplate = "/etc/systemd/system/wallarm-node@.service"
|
||||
BaseDir = "/opt/fw"
|
||||
Symlink = "/opt/wallarm"
|
||||
NginxDir = BaseDir + "/nginx"
|
||||
NodesDir = BaseDir
|
||||
)
|
||||
|
||||
func installerURL() string {
|
||||
|
|
@ -29,13 +29,14 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
|
|||
return fmt.Errorf("API token required")
|
||||
}
|
||||
|
||||
archiveDir := BaseDir
|
||||
installerPath := filepath.Join(archiveDir, "wallarm-aio.sh")
|
||||
instanceDir := filepath.Join(BaseDir, node.Name, "wallarm")
|
||||
installerPath := filepath.Join(BaseDir, "wallarm-aio.sh")
|
||||
_ = labels
|
||||
|
||||
// 1. Install NGINX
|
||||
// 1. Install NGINX (shared)
|
||||
installNginx()
|
||||
|
||||
// 2. Download AIO
|
||||
// 2. Download AIO once
|
||||
if _, err := os.Stat(installerPath); os.IsNotExist(err) {
|
||||
fmt.Printf("[%s] Downloading installer...\n", node.Name)
|
||||
cmd := exec.Command("curl", "-fsSL", "-o", installerPath, installerURL())
|
||||
|
|
@ -45,22 +46,25 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
|
|||
os.Chmod(installerPath, 0755)
|
||||
}
|
||||
|
||||
// 3. Extract once
|
||||
if _, err := os.Stat(filepath.Join(archiveDir, "setup.sh")); os.IsNotExist(err) {
|
||||
fmt.Printf("[%s] Extracting...\n", node.Name)
|
||||
cmd := exec.Command("bash", installerPath, "--noexec", "--keep", "--target", archiveDir, "--noprogress", "--accept")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("extract: %w\n%s", err, string(out))
|
||||
}
|
||||
// 3. Create instance dir + symlink (setup.sh hardcodes /opt/wallarm)
|
||||
os.MkdirAll(instanceDir, 0755)
|
||||
os.Remove(Symlink)
|
||||
os.Symlink(instanceDir, Symlink)
|
||||
|
||||
// 4. Extract AIO to instance via symlink
|
||||
fmt.Printf("[%s] Extracting...\n", node.Name)
|
||||
cmd := exec.Command("bash", installerPath, "--noexec", "--keep", "--target", instanceDir, "--noprogress", "--accept")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("extract: %w\n%s", err, string(out))
|
||||
}
|
||||
|
||||
// 4. Run setup
|
||||
// 5. Run setup.sh (sees /opt/wallarm → instance dir)
|
||||
fmt.Printf("[%s] Running setup...\n", node.Name)
|
||||
cmd := exec.Command("bash", filepath.Join(archiveDir, "setup.sh"),
|
||||
cmd = exec.Command("bash", filepath.Join(instanceDir, "setup.sh"),
|
||||
"--batch", "--token", apiToken, "--cloud", cloudFromHost(apiHost),
|
||||
)
|
||||
|
||||
logFile, _ := os.Create(filepath.Join(archiveDir, "install.log"))
|
||||
logFile, _ := os.Create(filepath.Join(instanceDir, "install.log"))
|
||||
if logFile != nil {
|
||||
cmd.Stdout = logFile
|
||||
cmd.Stderr = logFile
|
||||
|
|
@ -70,7 +74,7 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
|
|||
logFile.Close()
|
||||
}
|
||||
if runErr != nil {
|
||||
if data, _ := os.ReadFile(filepath.Join(archiveDir, "install.log")); len(data) > 0 {
|
||||
if data, _ := os.ReadFile(filepath.Join(instanceDir, "install.log")); len(data) > 0 {
|
||||
lines := strings.Split(string(data), "\n")
|
||||
s := len(lines) - 5
|
||||
if s < 0 {
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ func Run() Result {
|
|||
}
|
||||
|
||||
// 6. Installer reachability
|
||||
installerOk := shared.HTTPHead("https://storage.googleapis.com/meganode_storage/")
|
||||
installerOk := shared.HTTPHead("https://storage.googleapis.com/meganode_storage/6.13/")
|
||||
r.Checks = append(r.Checks, Check{
|
||||
Name: "installer_reachable", Passed: installerOk,
|
||||
Detail: "repo.wallarm.com",
|
||||
Detail: "storage.googleapis.com",
|
||||
})
|
||||
if !installerOk {
|
||||
r.Checks[len(r.Checks)-1].Warning = true
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
// StateDir is where wallarm stores its state (under /opt/wallarm/).
|
||||
const StateDir = "/opt/wallarm"
|
||||
const StateDir = "/opt/fw"
|
||||
|
||||
// State represents the persistent deployment state.
|
||||
type State struct {
|
||||
|
|
|
|||
5
setup.sh
5
setup.sh
|
|
@ -20,7 +20,7 @@ RED='\033[0;31m'
|
|||
NC='\033[0m'
|
||||
|
||||
REPO_URL="https://git.sechpoint.app/customer-engineering/wallarm.git"
|
||||
WALLARM_DIR="/opt/wallarm"
|
||||
WALLARM_DIR="/opt/fw"
|
||||
SOURCE_DIR="${WALLARM_DIR}/source"
|
||||
BUILD_DIR="/tmp/wallarm-build-$$"
|
||||
|
||||
|
|
@ -59,8 +59,7 @@ echo -e "${GREEN}git: $(git --version | cut -d' ' -f3) go: $(go version | cut -
|
|||
# ── Create /opt/wallarm/ ──────────────────────────────────────────────
|
||||
echo
|
||||
echo -e "${YELLOW}Creating /opt/wallarm/ directory structure...${NC}"
|
||||
mkdir -p "${WALLARM_DIR}/nodes"
|
||||
mkdir -p "${SOURCE_DIR}"
|
||||
mkdir -p "${WALLARM_DIR}"
|
||||
cd "${WALLARM_DIR}"
|
||||
echo -e "${GREEN} Done.${NC}"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue