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