mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
fix lost jq variant
This commit is contained in:
parent
2d8c278d74
commit
997cc0b28e
1 changed files with 5 additions and 9 deletions
|
|
@ -54,15 +54,11 @@ actionban = curl -s -X PUT "<_cf_api_url>" \
|
|||
# <time> unix timestamp of the ban time
|
||||
# Values: CMD
|
||||
#
|
||||
actionunban = id=$(curl -s -X GET "<_cf_api_url>?ip=<ip>" \
|
||||
<_cf_api_prms> \
|
||||
| awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'id'\042/){print $(i+1)}}}' \
|
||||
| tr -d ' "' \
|
||||
| head -n 1)
|
||||
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found using list <cflist>"; exit 0; fi; \
|
||||
curl -s -X DELETE "<_cf_api_url>" \
|
||||
<_cf_api_prms> \
|
||||
--data "{\"items\": [{\"id\":\"$id\"}]}"
|
||||
actionunban = id=$(curl -s -X GET <_cf_api_prms> \
|
||||
"<_cf_api_url>?ip=<ip>" \
|
||||
| { jq -r '.result[0].id' 2>/dev/null || awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'id'\042/){print $(i+1)}}}' | tr -d ' "' | head -n 1; })
|
||||
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found using list <cflist>"; exit 0; fi;
|
||||
curl -s -o /dev/null -X DELETE <_cf_api_prms> "<_cf_api_url>" --data "{\"items\": [{\"id\":\"$id\"}]}"
|
||||
|
||||
_cf_api_url = https://api.cloudflare.com/client/v4/accounts/<cfaccount>/rules/lists/<cflist>/items
|
||||
_cf_api_prms = -H "Authorization: Bearer <cftoken>" -H "Content-Type: application/json"
|
||||
|
|
|
|||
Loading…
Reference in a new issue