-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.sh
executable file
·26 lines (23 loc) · 909 Bytes
/
cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
PROG_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
source "${PROG_DIR}/.env" || exit 1
if [ -f /tmp/certbot_$CERTBOT_DOMAIN/RECORD_IDS ]; then
RECORD_IDS=$(cat /tmp/certbot_$CERTBOT_DOMAIN/RECORD_IDS)
# rm -f /tmp/certbot_$CERTBOT_DOMAIN/RECORD_IDS
rm -rf /tmp/certbot_$CERTBOT_DOMAIN/
fi
if [ "$(echo "$CERTBOT_DOMAIN" | cut -d "." -f 3)" == "" ] ; then
DOMAIN="$CERTBOT_DOMAIN"
else
DOMAIN="$(echo "$CERTBOT_DOMAIN" | cut -d "." -f 2).$(echo "$CERTBOT_DOMAIN" | cut -d "." -f 3)"
fi
# Remove the challenge TXT record from the zone
if [ -n "${RECORD_IDS}" ]; then
for RECORD_ID in $RECORD_IDS
do
echo "Remove TXT record from $CERTBOT_DOMAIN: $RECORD_ID"
curl -s -X DELETE "https://napi.arvancloud.ir/cdn/4.0/domains/$DOMAIN/dns-records/$RECORD_ID" \
-H "Authorization: $API_KEY"
echo
done
fi