Created
October 13, 2025 15:54
-
-
Save stefanpejcic/ba3dc86135f4e284b729629d5b83685e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| # Usage: bash csf_drop_country_from_deny_list.sh "<country-pattern>" | |
| # Examples: "RS/Serbia" "RS" "Serbia" | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: $0 <country-pattern>" | |
| exit 1 | |
| fi | |
| COUNTRY="$1" | |
| LOOP_WAIT=1 | |
| DENYFILE="/etc/csf/csf.deny" | |
| if [ ! -r "$DENYFILE" ]; then | |
| echo "Ne mogu da ocitam $DENYFILE" | |
| exit 2 | |
| fi | |
| grep -i -- "$COUNTRY" "$DENYFILE" \ | |
| | awk '{print $1}' \ | |
| | egrep -o '^([0-9]{1,3}\.){3}[0-9]{1,3}$' \ | |
| | while read -r ip; do | |
| echo "Remove: $ip" | |
| csf -dr "$ip" || echo "Upozorenje: csf -dr vrati pogresku za $ip" | |
| sleep "$LOOP_WAIT" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment