fix lost jq variant

This commit is contained in:
Robert Vojcik 2025-12-10 18:01:10 +01:00
parent 2d8c278d74
commit 997cc0b28e

View file

@ -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"