diff --git a/cmd/wallarm/main.go b/cmd/wallarm/main.go index eae5fb5..b89d3e1 100644 --- a/cmd/wallarm/main.go +++ b/cmd/wallarm/main.go @@ -179,7 +179,13 @@ WALLARM_REGION=%s } 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() { fmt.Println() diff --git a/deploy.sh b/deploy.sh index 1901369..e9108d2 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,14 +1,14 @@ #!/bin/bash # ============================================================================== -# Wallarm Deployment — Source-based Bootstrap +# Wallarm Deployment — Single Binary Bootstrap # ============================================================================== -# Clones the repository and builds the wallarm binary from source. -# One command to get started: +# Clones the repository, builds the wallarm binary, and installs it to +# /opt/wallarm/. One command to get started: # # 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 @@ -21,7 +21,7 @@ RED='\033[0;31m' NC='\033[0m' REPO_URL="https://git.sechpoint.app/customer-engineering/wallarm.git" -DEPLOY_DIR="${HOME:-/root}/deploy" +WALLARM_DIR="/opt/wallarm" BUILD_DIR="/tmp/wallarm-build-$$" cleanup() { rm -rf "$BUILD_DIR"; } @@ -76,15 +76,15 @@ if command -v upx >/dev/null 2>&1; then fi # ── Install ─────────────────────────────────────────────────────────── -mkdir -p "$DEPLOY_DIR" -cp wallarm "$DEPLOY_DIR/wallarm" -chmod +x "$DEPLOY_DIR/wallarm" +mkdir -p "$WALLARM_DIR" +cp wallarm "$WALLARM_DIR/wallarm" +chmod +x "$WALLARM_DIR/wallarm" echo echo -e "${GREEN}${BOLD}Ready!${NC}" echo -echo -e " ${CYAN}sudo ${DEPLOY_DIR}/wallarm${NC} — Start the TUI" -echo -e " ${CYAN}${DEPLOY_DIR}/wallarm --help${NC} — Show all commands" -echo -e " ${CYAN}${DEPLOY_DIR}/wallarm --tunnel${NC} — Start remote tunnel" +echo -e " ${CYAN}sudo ${WALLARM_DIR}/wallarm${NC} — Start the TUI" +echo -e " ${CYAN}${WALLARM_DIR}/wallarm --help${NC} — Show all commands" +echo -e " ${CYAN}${WALLARM_DIR}/wallarm --tunnel${NC} — Start remote tunnel" echo -ls -lh "$DEPLOY_DIR/wallarm" +ls -lh "$WALLARM_DIR/wallarm" diff --git a/internal/state/state.go b/internal/state/state.go index 2d8834a..0b3bfeb 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -5,11 +5,10 @@ import ( "encoding/json" "fmt" "os" - "path/filepath" ) -// StateDir is where wallarm stores its state. -const StateDir = ".wallarm" +// StateDir is where wallarm stores its state (under /opt/wallarm/). +const StateDir = "/opt/wallarm" // State represents the persistent deployment state. type State struct { @@ -34,11 +33,7 @@ type Node struct { // Path returns the full path to the state file. func Path() string { - home, err := os.UserHomeDir() - if err != nil { - home = "/root" - } - return filepath.Join(home, StateDir, "state.json") + return StateDir + "/state.json" } // 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 } -// Save writes the state to disk, creating directories as needed. +// Save writes the state to /opt/wallarm/state.json. func Save(s *State) error { 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) } data, err := json.MarshalIndent(s, "", " ")