From 0fe38472e9a6e0a780b61b4a428cd23b915ed7f5 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Tue, 19 Nov 2024 05:13:24 +0100 Subject: [PATCH] Bugfix for install.sh --- install.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index cf1a814..333957d 100644 --- a/install.sh +++ b/install.sh @@ -158,25 +158,24 @@ echo -e "INFO: reporter.sh has been made executable.\n" # =========================== AbuseIPDB API token =========================== max_attempts=4 -attempts=0 -valid_token=false -while [[ $attempts -lt $max_attempts ]]; do +for ((attempts = 0; attempts < max_attempts; attempts++)); do read -rsp "$ Please enter your AbuseIPDB API token: " api_key echo if validate_token "$api_key"; then valid_token=true break - else - attempts_left=$((max_attempts - attempts - 1)) + fi + + attempts_left=$((max_attempts - attempts - 1)) + if (( attempts_left > 0 )); then echo "WARN: Invalid API token format. Please enter an 80-character hexadecimal string. You have $attempts_left/$max_attempts attempts left." - ((attempts++)) fi done -if [[ "$valid_token" == "false" ]]; then - echo -e "\nFAIL: Maximum number of attempts reached. Installation aborted!" +if [[ "${valid_token:-false}" != true ]]; then + echo "FAIL: Maximum number of attempts reached. Installation aborted!" exit 1 fi