diff --git a/wallarm-deploy-ct.sh b/wallarm-deploy-ct.sh index 98660b1..9855d6e 100644 --- a/wallarm-deploy-ct.sh +++ b/wallarm-deploy-ct.sh @@ -24,27 +24,45 @@ echo -e "${BLUE}====================================================${NC}" check_connectivity() { echo -e "\n${YELLOW}[1/5] Testing Cloud & Registry Connectivity...${NC}" + # 1. Cloud Selection read -p " Wallarm Cloud (US/EU) [US]: " CLOUD_SEL - CLOUD_SEL=${CLOUD_SEL^^}; CLOUD_SEL=${CLOUD_SEL:-US} + CLOUD_SEL=${CLOUD_SEL^^} + CLOUD_SEL=${CLOUD_SEL:-US} local nodes_to_test=("${US_DATA_NODES[@]}") [[ "$CLOUD_SEL" == "EU" ]] && nodes_to_test=("${EU_DATA_NODES[@]}") + # 2. Test Wallarm API Endpoints + echo " Testing $CLOUD_SEL Cloud Endpoints..." for node in "${nodes_to_test[@]}"; do if curl -skI --connect-timeout 5 "https://$node" > /dev/null 2>&1; then - echo -e " ${GREEN}[PASS]${NC} Reached $node" + echo -e " ${GREEN}[PASS]${NC} Reached $node" else - echo -e " ${RED}[FAIL]${NC} Cannot reach $node (Check Firewall/Proxy)" + echo -e " ${RED}[FAIL]${NC} Cannot reach $node (Check Firewall/Proxy)" fi done API_HOST=$([[ "$CLOUD_SEL" == "EU" ]] && echo "api.wallarm.com" || echo "us1.api.wallarm.com") - # Check Registry for Pull Capability - REGISTRY_REACHABLE=true - if ! curl -skI --connect-timeout 5 "https://registry-1.docker.io/v2/" > /dev/null 2>&1; then + # 3. Improved Docker Registry Check (Accepting 401 as 'Reachable') + echo -n " Testing Docker Hub Registry Path... " + + # Capture the HTTP Status code specifically + REGISTRY_STATUS=$(curl -skI --connect-timeout 5 -o /dev/null -w "%{http_code}" "https://registry-1.docker.io/v2/") + + # 401 (Unauthorized) is the expected response from Docker Hub V2 API for unauthenticated probes + if [[ "$REGISTRY_STATUS" == "200" || "$REGISTRY_STATUS" == "401" ]]; then + REGISTRY_REACHABLE=true + echo -e "${GREEN}REACHABLE${NC} (Status: $REGISTRY_STATUS)" + else REGISTRY_REACHABLE=false - echo -e " ${YELLOW}[WARN]${NC} Docker Hub unreachable. Will look for local .tar image." + echo -e "${RED}BLOCKED/OFFLINE${NC} (Status: $REGISTRY_STATUS)" + echo -e " ${YELLOW}i${NC} Falling back to local image check..." + + if ! ls *.tar >/dev/null 2>&1; then + echo -e " ${RED}✗ FATAL: Registry unreachable and no local .tar image found.${NC}" + exit 1 + fi fi }