refactor: move everything under /opt/wallarm/
- deploy.sh installs to /opt/wallarm/wallarm (not ~/deploy/)
- state.json at /opt/wallarm/state.json (not ~/.wallarm/)
- instances under /opt/wallarm/{name}/
- .env will live at /opt/wallarm/.env for global defaults
- Single tree, no home directory clutter
This commit is contained in:
parent
f5919b4c85
commit
e2c0f5af08
3 changed files with 25 additions and 24 deletions
|
|
@ -179,7 +179,13 @@ WALLARM_REGION=%s
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("✅ Deployment complete! Run 'wallarm' again for the dashboard.")
|
fmt.Println("✅ Deployment complete!")
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Printf(" Binary: /opt/wallarm/wallarm\n")
|
||||||
|
fmt.Printf(" Instance: %s\n", instanceDir)
|
||||||
|
fmt.Printf(" State: /opt/wallarm/state.json\n")
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println("Run 'sudo /opt/wallarm/wallarm' for the dashboard.")
|
||||||
}
|
}
|
||||||
func runTunnelFlow() {
|
func runTunnelFlow() {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
|
||||||
26
deploy.sh
26
deploy.sh
|
|
@ -1,14 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Wallarm Deployment — Source-based Bootstrap
|
# Wallarm Deployment — Single Binary Bootstrap
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Clones the repository and builds the wallarm binary from source.
|
# Clones the repository, builds the wallarm binary, and installs it to
|
||||||
# One command to get started:
|
# /opt/wallarm/. One command to get started:
|
||||||
#
|
#
|
||||||
# curl -fsSL ".../deploy.sh" | bash
|
# curl -fsSL ".../deploy.sh" | bash
|
||||||
# sudo ./deploy/wallarm
|
# sudo /opt/wallarm/wallarm
|
||||||
#
|
#
|
||||||
# Requires: git, go (auto-installed if missing on apt/yum systems)
|
# All deployments live under /opt/wallarm/ — binary, config, instances, state.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
@ -21,7 +21,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"
|
||||||
DEPLOY_DIR="${HOME:-/root}/deploy"
|
WALLARM_DIR="/opt/wallarm"
|
||||||
BUILD_DIR="/tmp/wallarm-build-$$"
|
BUILD_DIR="/tmp/wallarm-build-$$"
|
||||||
|
|
||||||
cleanup() { rm -rf "$BUILD_DIR"; }
|
cleanup() { rm -rf "$BUILD_DIR"; }
|
||||||
|
|
@ -76,15 +76,15 @@ if command -v upx >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Install ───────────────────────────────────────────────────────────
|
# ── Install ───────────────────────────────────────────────────────────
|
||||||
mkdir -p "$DEPLOY_DIR"
|
mkdir -p "$WALLARM_DIR"
|
||||||
cp wallarm "$DEPLOY_DIR/wallarm"
|
cp wallarm "$WALLARM_DIR/wallarm"
|
||||||
chmod +x "$DEPLOY_DIR/wallarm"
|
chmod +x "$WALLARM_DIR/wallarm"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${GREEN}${BOLD}Ready!${NC}"
|
echo -e "${GREEN}${BOLD}Ready!${NC}"
|
||||||
echo
|
echo
|
||||||
echo -e " ${CYAN}sudo ${DEPLOY_DIR}/wallarm${NC} — Start the TUI"
|
echo -e " ${CYAN}sudo ${WALLARM_DIR}/wallarm${NC} — Start the TUI"
|
||||||
echo -e " ${CYAN}${DEPLOY_DIR}/wallarm --help${NC} — Show all commands"
|
echo -e " ${CYAN}${WALLARM_DIR}/wallarm --help${NC} — Show all commands"
|
||||||
echo -e " ${CYAN}${DEPLOY_DIR}/wallarm --tunnel${NC} — Start remote tunnel"
|
echo -e " ${CYAN}${WALLARM_DIR}/wallarm --tunnel${NC} — Start remote tunnel"
|
||||||
echo
|
echo
|
||||||
ls -lh "$DEPLOY_DIR/wallarm"
|
ls -lh "$WALLARM_DIR/wallarm"
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// StateDir is where wallarm stores its state.
|
// StateDir is where wallarm stores its state (under /opt/wallarm/).
|
||||||
const StateDir = ".wallarm"
|
const StateDir = "/opt/wallarm"
|
||||||
|
|
||||||
// State represents the persistent deployment state.
|
// State represents the persistent deployment state.
|
||||||
type State struct {
|
type State struct {
|
||||||
|
|
@ -34,11 +33,7 @@ type Node struct {
|
||||||
|
|
||||||
// Path returns the full path to the state file.
|
// Path returns the full path to the state file.
|
||||||
func Path() string {
|
func Path() string {
|
||||||
home, err := os.UserHomeDir()
|
return StateDir + "/state.json"
|
||||||
if err != nil {
|
|
||||||
home = "/root"
|
|
||||||
}
|
|
||||||
return filepath.Join(home, StateDir, "state.json")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load reads and parses the state file. Returns nil if the file doesn't exist.
|
// Load reads and parses the state file. Returns nil if the file doesn't exist.
|
||||||
|
|
@ -58,10 +53,10 @@ func Load() (*State, error) {
|
||||||
return &s, nil
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save writes the state to disk, creating directories as needed.
|
// Save writes the state to /opt/wallarm/state.json.
|
||||||
func Save(s *State) error {
|
func Save(s *State) error {
|
||||||
p := Path()
|
p := Path()
|
||||||
if err := os.MkdirAll(filepath.Dir(p), 0700); err != nil {
|
if err := os.MkdirAll(StateDir, 0755); err != nil {
|
||||||
return fmt.Errorf("create state dir: %w", err)
|
return fmt.Errorf("create state dir: %w", err)
|
||||||
}
|
}
|
||||||
data, err := json.MarshalIndent(s, "", " ")
|
data, err := json.MarshalIndent(s, "", " ")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue