From 6fb234931297b85cb55a0426f679ba40c17f32c8 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Sat, 18 Jan 2025 03:12:04 +0100 Subject: [PATCH] Small fixes --- install.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 2917b53..0d7a20e 100644 --- a/install.sh +++ b/install.sh @@ -56,15 +56,24 @@ check_dependencies # Function to validate AbuseIPDB API key validate_token() { local api_key=$1 + local api_url="https://api.abuseipdb.com/api/v2/check?ipAddress=8.8.8.8" local response - response=$(curl -s -o /dev/null -w "%{http_code}" -H "Key: $api_key" https://api.abuseipdb.com/api/v2/check?ipAddress=8.8.8.8) + if command -v curl &>/dev/null; then + response=$(curl -s -o /dev/null -w "%{http_code}" -H "Key: $api_key" "$api_url") + elif command -v wget &>/dev/null; then + response=$(wget --quiet --server-response --header="Key: $api_key" --output-document=/dev/null "$api_url" 2>&1 | awk '/HTTP\/1\.[01] [0-9]{3}/ {print $2}' | tail -n1) + else + echo "❌ Neither curl nor wget is installed. Please install one of them to proceed." + exit 1 + fi if [[ $response -eq 200 ]]; then + echo "✅ Yay! Token is valid." return 0 else - echo "🚨 Invalid token. Please try again." - return 1 + echo "🚨 Invalid token or an error occurred! Please try again." + exit 1 fi }