Last active
September 12, 2025 06:39
-
-
Save garrydzeng/0f9282ae74af838c9fad244b0351d831 to your computer and use it in GitHub Desktop.
Script for alidns + certbot --manual-auth-hook & --manual-cleanup-hook
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
| #!/usr/bin/env bash | |
| set -e | |
| which aliyun &> /dev/null | |
| if [[ $? -eq 0 ]]; then | |
| aliyun alidns AddDomainRecord --DomainName $CERTBOT_DOMAIN --RR _acme-challenge --Type TXT --Value $CERTBOT_VALIDATION | |
| fi |
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
| #!/usr/bin/env bash | |
| set -u | |
| which aliyun jq &> /dev/null | |
| if [[ $? -eq 0 ]]; then | |
| set -euo pipefail | |
| PAGE=1 | |
| while true; do | |
| LIST=$(aliyun alidns DescribeDomainRecords --DomainName $CERTBOT_DOMAIN --Type TXT --RRKeyWord _acme-challenge --PageNumber $PAGE | jq -r .DomainRecords.Record[].RecordId) | |
| if [[ -z $LIST ]]; then | |
| break | |
| fi | |
| ((PAGE++)) | |
| echo "$LIST" | while read -r ID; do | |
| aliyun alidns DeleteDomainRecord --RecordId $ID | |
| done | |
| done | |
| fi |
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
| certbot certonly -d *.example.com -d example.com --preferred-chain 'ISRG Root X2' --preferred-challenges dns --manual --manual-auth-hook /usr/local/etc/letsencrypt/authenticate.sh --manual-cleanup-hook /usr/local/etc/letsencrypt/clear.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment