Small fixes

This commit is contained in:
Sefinek committed 2024-11-19 05:20:18 +01:00
1 parent 0fe38472e9
commit d24cb1d0d6
2 files changed
+7 -18

No files matched your search

+6 -17
View File
@@ -52,16 +52,6 @@ download_file() {
fi fi
} }
# Function to validate the API token format
validate_token() {
local token="$1"
if [[ "$token" =~ ^[a-f0-9]{80}$ ]]; then
return 0
else
return 1
fi
}
# Ask # Ask
ask_user() { ask_user() {
local question="$1" local question="$1"
@@ -158,12 +148,12 @@ echo -e "INFO: reporter.sh has been made executable.\n"
# =========================== AbuseIPDB API token =========================== # =========================== AbuseIPDB API token ===========================
max_attempts=4 max_attempts=4
valid_token=false
for ((attempts = 0; attempts < max_attempts; attempts++)); do for ((attempts = 0; attempts < max_attempts; attempts++)); do
read -rsp "$ Please enter your AbuseIPDB API token: " api_key read -rsp "$ Please enter your AbuseIPDB API token: " api_key
echo echo
if validate_token "$api_key"; then if [[ "$api_key" =~ ^[a-f0-9]{80}$ ]]; then
valid_token=true valid_token=true
break break
fi fi
@@ -174,7 +164,7 @@ for ((attempts = 0; attempts < max_attempts; attempts++)); do
fi fi
done done
if [[ "${valid_token:-false}" != true ]]; then if [[ "$valid_token" != true ]]; then
echo "FAIL: Maximum number of attempts reached. Installation aborted!" echo "FAIL: Maximum number of attempts reached. Installation aborted!"
exit 1 exit 1
fi fi
@@ -247,12 +237,11 @@ EOF
exit 1 exit 1
fi fi
else else
echo "INFO: reporter.sh will not be added as a service..." echo -e "INFO: reporter.sh will not be added as a service. Running the script directly... Press ^C to stop.\n"
echo "INFO: Running reporter.sh directly. Press ^C to stop the script."
if "$script_path"; then if "$script_path"; then
echo "INFO: reporter.sh executed successfully!" echo "INFO: reporter.sh executed successfully."
else else
echo "FAIL: Failed to execute reporter.sh." echo "FAIL: Failed to execute reporter.sh!"
exit 1 exit 1
fi fi
fi fi
+1 -1
View File
@@ -55,7 +55,7 @@ load_reported_ips() {
done < "$REPORTED_IPS_FILE" done < "$REPORTED_IPS_FILE"
log "INFO" "Loaded ${#reported_ips[@]} IPs from $REPORTED_IPS_FILE" log "INFO" "Loaded ${#reported_ips[@]} IPs from $REPORTED_IPS_FILE"
else else
log "INFO" "$REPORTED_IPS_FILE does not exist. No data to load!" log "INFO" "$REPORTED_IPS_FILE does not exist. No data to load."
fi fi
} }