Bugfix for install.sh

This commit is contained in:
Sefinek 2024-11-19 05:01:06 +01:00
parent ba4c2b6161
commit d1893af96f

View file

@ -34,20 +34,20 @@ about the latest changes and more: https://discord.gg/53DBjTuzgZ
EOF EOF
# Function to download a file using either wget or curl # Function to download a file using either curl or wget
download_file() { download_file() {
local url="$1" local url="$1"
local output="$2" local output="$2"
local user_agent="UFW-AbuseIPDB-Reporter/$VERSION (+$REPO)" local user_agent="UFW-AbuseIPDB-Reporter/$VERSION (+$REPO)"
if command -v wget >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1; then
echo "INFO: Using 'wget' to download the file..." echo "INFO: Using 'curl' to download the file..."
sudo wget --header="User-Agent: $user_agent" -O "$output" "$url"
elif command -v curl >/dev/null 2>&1; then
echo "INFO: 'wget' is not installed. Switching to 'curl' to download the file..."
sudo curl -A "$user_agent" -o "$output" "$url" sudo curl -A "$user_agent" -o "$output" "$url"
elif command -v wget >/dev/null 2>&1; then
echo "INFO: 'curl' is not installed. Using 'wget' to download the file..."
sudo wget --header="User-Agent: $user_agent" -O "$output" "$url"
else else
echo "FAIL: Neither 'wget' nor 'curl' is installed! Please install one of these packages and try running the script again." echo "FAIL: Neither 'curl' nor 'wget' is installed! Please install one of these packages and try running the script again."
exit 1 exit 1
fi fi
} }
@ -141,8 +141,8 @@ echo
# =========================== Prepare reporter.sh script =========================== # =========================== Prepare reporter.sh script ===========================
GITHUB_URL="https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/reporter.sh..." GITHUB_URL="https://raw.githubusercontent.com/sefinek/UFW-AbuseIPDB-Reporter/main/reporter.sh"
echo "INFO: Downloading reporter.sh from $GITHUB_URL" echo "INFO: Downloading reporter.sh from $GITHUB_URL..."
if ! download_file "$GITHUB_URL" "$script_path"; then if ! download_file "$GITHUB_URL" "$script_path"; then
echo "FAIL: Something went wrong while downloading the file from GitHub servers! Maybe try running this script as sudo?" echo "FAIL: Something went wrong while downloading the file from GitHub servers! Maybe try running this script as sudo?"
exit 1 exit 1
@ -176,7 +176,7 @@ while [[ $attempts -lt $max_attempts ]]; do
done done
if [[ "$valid_token" = false ]]; then if [[ "$valid_token" = false ]]; then
echo "FAIL: Maximum number of attempts reached. Installation aborted!" echo -e "\nFAIL: Maximum number of attempts reached. Installation aborted!"
exit 1 exit 1
fi fi