From 1859bfa4308bf3062b468eb2659edbaea62cbb21 Mon Sep 17 00:00:00 2001 From: Brynley Llewellyn-Roux Date: Mon, 17 Feb 2025 07:56:57 +1100 Subject: [PATCH] fix: update `certs-gc.sh` --- scripts/certs-gc.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/certs-gc.sh b/scripts/certs-gc.sh index 47c19113..d4b3ea1b 100755 --- a/scripts/certs-gc.sh +++ b/scripts/certs-gc.sh @@ -1,13 +1,15 @@ #!/usr/bin/env sh -response=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/ssl/certificate_packs" \ +domain="$1" + +response=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/ssl/certificate_packs" \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $POLYKEY_DOCS_CLOUDFLARE_CLEANUP_TOKEN") + -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN") -cert_ids=$(echo "$response" | jq -r --arg domain "$DOMAIN" '.result[] | select(.hosts[] | contains($domain)) | .id') +cert_ids=$(echo "$response" | jq -r --arg domain "$domain" '.result[] | select(.hosts[] | contains($domain)) | .id') echo "$cert_ids" | while read -r cert_id; do - curl -X DELETE --url "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/ssl/certificate_packs/$cert_id" \ + curl -X DELETE --url "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/ssl/certificate_packs/$cert_id" \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $POLYKEY_DOCS_CLOUDFLARE_CLEANUP_TOKEN" + -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" done