update
This commit is contained in:
parent
159e6e33e0
commit
f1c184a234
1 changed files with 40 additions and 14 deletions
|
|
@ -17,19 +17,24 @@ APP_PORT=${APP_PORT:-8080}
|
||||||
|
|
||||||
# --- 2. SUDO & SYSTEM CHECK ---
|
# --- 2. SUDO & SYSTEM CHECK ---
|
||||||
echo -e "\n${YELLOW}[1/4] Checking Sudo & OS Status...${NC}"
|
echo -e "\n${YELLOW}[1/4] Checking Sudo & OS Status...${NC}"
|
||||||
if sudo -n true 2>/dev/null; then
|
|
||||||
echo -e "${GREEN}[PASS]${NC} Sudo is active/passwordless."
|
# Improved Sudo Check: Try a non-destructive command with sudo
|
||||||
|
echo "Checking sudo permissions (you may be prompted for a password)..."
|
||||||
|
if sudo -v; then
|
||||||
|
echo -e "${GREEN}[PASS]${NC} User has sudo privileges."
|
||||||
else
|
else
|
||||||
echo -e "${RED}[FAIL]${NC} Sudo requires a password or user is not in sudoers."
|
echo -e "${RED}[FAIL]${NC} User is NOT in sudoers or password was incorrect."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect OS and try to update/install basics
|
# Detect OS and try to update/install basics
|
||||||
if [ -f /etc/debian_version ]; then
|
if [ -f /etc/debian_version ]; then
|
||||||
echo "OS: Debian/Ubuntu detected. Checking packages..."
|
echo "OS: Debian/Ubuntu detected."
|
||||||
sudo apt-get update -qq && sudo apt-get install -y curl wget git netcat-openbsd -qq > /dev/null
|
# sudo apt-get update -qq && sudo apt-get install -y curl wget git -qq > /dev/null
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [ -f /etc/redhat-release ]; then
|
||||||
echo "OS: RHEL/CentOS detected. Checking packages..."
|
echo "OS: RHEL/CentOS detected."
|
||||||
sudo yum makecache -q && sudo yum install -y curl wget git nc -q > /dev/null
|
# sudo yum makecache -q && sudo yum install -y curl wget git -q > /dev/null
|
||||||
|
else
|
||||||
|
echo "OS: Non-Linux (Mac/Other) detected. Network tests will use 'curl' fallback."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 3. TOOL VERIFICATION ---
|
# --- 3. TOOL VERIFICATION ---
|
||||||
|
|
@ -48,11 +53,22 @@ echo -e "\n${YELLOW}[3/4] Testing Wallarm Cloud Connectivity (Port 443)...${NC}"
|
||||||
test_conn() {
|
test_conn() {
|
||||||
local target=$1
|
local target=$1
|
||||||
local desc=$2
|
local desc=$2
|
||||||
# Linux-native check. Note: Won't work on default macOS Bash, but perfect for Linux VMs.
|
|
||||||
if timeout 3 bash -c "cat < /dev/null > /dev/tcp/$target/443" 2>/dev/null; then
|
# Check if we are on Linux (which supports /dev/tcp) or Mac
|
||||||
echo -e "${GREEN}[PASS]${NC} $desc ($target)"
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# Mac Fallback: Use curl to check connection
|
||||||
|
if curl -sk --connect-timeout 3 "https://$target" > /dev/null 2>&1 || [ $? -eq 45 ] || [ $? -eq 35 ]; then
|
||||||
|
echo -e "${GREEN}[PASS]${NC} $desc ($target)"
|
||||||
|
else
|
||||||
|
echo -e "${RED}[FAIL]${NC} $desc ($target) - BLOCKED"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}[FAIL]${NC} $desc ($target) - BLOCKED"
|
# Linux Native: Faster and more reliable in locked-down environments
|
||||||
|
if timeout 3 bash -c "cat < /dev/null > /dev/tcp/$target/443" 2>/dev/null; then
|
||||||
|
echo -e "${GREEN}[PASS]${NC} $desc ($target)"
|
||||||
|
else
|
||||||
|
echo -e "${RED}[FAIL]${NC} $desc ($target) - BLOCKED"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,10 +87,20 @@ test_conn "35.235.115.105" "Extra US-3"
|
||||||
|
|
||||||
# --- 5. INTERNAL APP CHECK ---
|
# --- 5. INTERNAL APP CHECK ---
|
||||||
echo -e "\n${YELLOW}[4/4] Testing Internal App Connectivity...${NC}"
|
echo -e "\n${YELLOW}[4/4] Testing Internal App Connectivity...${NC}"
|
||||||
if timeout 3 bash -c "cat < /dev/null > /dev/tcp/$APP_HOST/$APP_PORT" 2>/dev/null; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
echo -e "${GREEN}[PASS]${NC} Reached App at $APP_HOST:$APP_PORT"
|
# Mac check for the app port specifically
|
||||||
|
if curl -s --connect-timeout 3 "$APP_HOST:$APP_PORT" > /dev/null 2>&1 || [ $? -eq 52 ] || [ $? -eq 45 ]; then
|
||||||
|
echo -e "${GREEN}[PASS]${NC} Reached App at $APP_HOST:$APP_PORT"
|
||||||
|
else
|
||||||
|
echo -e "${RED}[FAIL]${NC} Cannot reach $APP_HOST on port $APP_PORT"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}[FAIL]${NC} CANNOT REACH $APP_HOST on port $APP_PORT"
|
# Linux native check
|
||||||
|
if timeout 3 bash -c "cat < /dev/null > /dev/tcp/$APP_HOST/$APP_PORT" 2>/dev/null; then
|
||||||
|
echo -e "${GREEN}[PASS]${NC} Reached App at $APP_HOST:$APP_PORT"
|
||||||
|
else
|
||||||
|
echo -e "${RED}[FAIL]${NC} CANNOT REACH $APP_HOST on port $APP_PORT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n${YELLOW}-------------------------------------------------------"
|
echo -e "\n${YELLOW}-------------------------------------------------------"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue