#!/bin/bash # ============================================================================== # Wallarm Deployment Setup Script # ============================================================================== # Downloads all necessary Wallarm deployment scripts from GitLab repository # and makes them executable. # ============================================================================== set -euo pipefail # Color definitions RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[1;34m' CYAN='\033[0;36m' BOLD='\033[1m' NC='\033[0m' # Base URLs for GitLab raw content GITLAB_BASE="https://git.sechpoint.app/customer-engineering/wallarm/-/raw/main" SCRIPTS=( "wallarm-ct-check.sh" "wallarm-ct-deploy.sh" "wallarm-ct-reconfigure.sh" "wallarm-ct-uninstall.sh" ) # Detect download command (curl preferred, fallback to wget) if command -v curl >/dev/null 2>&1; then DOWNLOAD_CMD="curl -fL -O" DOWNLOAD_NAME="curl" elif command -v wget >/dev/null 2>&1; then DOWNLOAD_CMD="wget -q" DOWNLOAD_NAME="wget" else echo -e "${RED}${BOLD}ERROR:${NC} Neither curl nor wget is installed." echo -e "Please install one of them and run this script again." exit 1 fi # Function to download a script download_script() { local script="$1" local url="${GITLAB_BASE}/${script}" echo -e "${YELLOW}Downloading ${script}...${NC}" if [ -f "$script" ]; then echo -e "${YELLOW} File already exists. Overwrite? (y/N)${NC}" read -r answer if [[ ! "$answer" =~ ^[Yy]$ ]]; then echo -e "${BLUE} Skipping.${NC}" return 0 fi rm -f "$script" fi if [ "$DOWNLOAD_NAME" = "curl" ]; then curl -fL "$url" -o "$script" else wget -q "$url" -O "$script" fi if [ $? -eq 0 ] && [ -s "$script" ]; then chmod +x "$script" echo -e "${GREEN} Success: ${script} downloaded and made executable.${NC}" else echo -e "${RED} Failed to download ${script}. Check network connectivity.${NC}" exit 1 fi } # Main clear echo -e "${BLUE}${BOLD}" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ WALLARM DEPLOYMENT SETUP SCRIPT ║" echo "║ Downloads all necessary deployment tools ║" echo "╚══════════════════════════════════════════════════════════════╝${NC}" echo # Check for existing scripts and provide option to skip all if ls wallarm-ct-*.sh 2>/dev/null | grep -q .; then echo -e "${YELLOW}Existing Wallarm scripts found.${NC}" echo -e "${YELLOW}Do you want to re-download all? (y/N)${NC}" read -r answer if [[ ! "$answer" =~ ^[Yy]$ ]]; then echo -e "${BLUE}Exiting without changes.${NC}" exit 0 fi fi # Download each script for script in "${SCRIPTS[@]}"; do download_script "$script" done echo echo -e "${GREEN}${BOLD}All scripts downloaded successfully!${NC}" echo echo -e "${CYAN}Next steps:${NC}" echo -e " 1. Run the preflight check: ${YELLOW}./wallarm-ct-check.sh${NC}" echo -e " 2. Deploy a Wallarm node: ${YELLOW}./wallarm-ct-deploy.sh${NC}" echo -e " 3. Reconfigure existing node: ${YELLOW}./wallarm-ct-reconfigure.sh${NC}" echo -e " 4. Uninstall a node: ${YELLOW}./wallarm-ct-uninstall.sh${NC}" echo echo -e "${YELLOW}Note: Some scripts require sudo. Run them with: sudo ./