#!/bin/bash # --- Styling --- RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}=== Sechpoint Wallarm PRE-DEPLOYMENT-TEST ===${NC}" echo "Please answer the following questions to verify VM readiness." echo "-------------------------------------------------------" # 1. Interactive Input read -p "Enter Application Server IP/Hostname: " APP_HOST read -p "Enter Application Server Port (e.g. 8080): " APP_PORT echo "" # 2. Check Sudo & Update Packages echo -e "${YELLOW}[1/4] Checking Sudo & Updating Package Lists...${NC}" if sudo -n true 2>/dev/null; then echo -e "${GREEN}[PASS]${NC} Sudo is active/passwordless." else echo -e "${RED}[FAIL]${NC} Sudo requires a password or user is not in sudoers." echo " Please ensure 'su -' or passwordless sudo is configured." fi # Detect OS and install basics if [ -f /etc/debian_version ]; then sudo apt-get update -y && sudo apt-get install -y nano curl wget git netcat-openbsd elif [ -f /etc/redhat-release ]; then sudo yum makecache && sudo yum install -y nano curl wget git nc fi # 3. Check Required Tools echo -e "\n${YELLOW}[2/4] Verifying Installed Tools...${NC}" for tool in nano curl wget git nc; do if command -v $tool &> /dev/null; then echo -e "${GREEN}[PASS]${NC} $tool is installed." else echo -e "${RED}[FAIL]${NC} $tool failed to install." fi done # 4. Check Wallarm Cloud Connectivity echo -e "\n${YELLOW}[3/4] Checking Wallarm Cloud Connections...${NC}" check_conn() { curl -Is --connect-timeout 5 "$1" | head -n 1 | grep -q "200\|301\|302\|404\|401" if [ $? -eq 0 ]; then echo -e "${GREEN}[PASS]${NC} Reachable: $1" else echo -e "${RED}[FAIL]${NC} UNREACHABLE: $1" fi } check_conn "https://api.wallarm.com" # US Cloud check_conn "https://api.wallarm.eu" # EU Cloud # 5. Check Backend Application Connectivity echo -e "\n${YELLOW}[4/4] Checking Backend App Connectivity...${NC}" if nc -zv -w 5 "$APP_HOST" "$APP_PORT" 2>&1 | grep -q "succeeded\|open"; then echo -e "${GREEN}[PASS]${NC} Connection to $APP_HOST:$APP_PORT successful." else echo -e "${RED}[FAIL]${NC} CANNOT REACH $APP_HOST on port $APP_PORT." fi echo -e "\n${YELLOW}-------------------------------------------------------" echo -e "PRE-DEPLOYMENT-TEST COMPLETE. PLEASE TAKE A SCREENSHOT OF THIS OUTPUT." echo -e "-------------------------------------------------------${NC}"