-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.sh
46 lines (36 loc) · 1.39 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
_dir="$(dirname "$0")"
source "$_dir/config.sh"
DOMAIN=$(expr match "$CERTBOT_DOMAIN" '.*\.\(.*\..*\)')
## get_dns_domains record
CREATE_DOMAIN="_acme-challenge.$DOMAIN"
echo Removing: $CREATE_DOMAIN
dns_id=$(curl -s -X POST $HostWindsAPI \
-H "Content-Type: application/json" \
--data '{"action":"get_dns_domains","search":"'"$DOMAIN"'","API":"'"$API_KEY"'"}' \
| jq .success[].id )
echo DNS ID: $dns_id
## get_dns_records
dns_rec_id=$(curl -s -X POST $HostWindsAPI \
-H "Content-Type: application/json" \
--data '{"action":"get_dns_records","id":"'"$dns_id"'","API":"'"$API_KEY"'"}' \
| jq '.success[] | select(.name=="_acme-challenge.'$DOMAIN'")' | jq .id )
echo DNS Rec IDs: $dns_rec_id
## get_locations
get_locations=$(curl -s -X POST $HostWindsAPI \
-H "Content-Type: application/json" \
--data '{"action":"get_locations","API":"'"$API_KEY"'"}' \
| jq .success | jq 'keys[0]' )
echo Locatiion IDs: $get_locations
curl_data=$(jq -n \
--arg action "delete_dns_record" \
--arg dns_rid "$dns_rec_id" \
--arg api "$API_KEY" \
--argjson gloc "$get_locations" \
'{action:$action, id:$dns_rid, API:$api, location_id:$gloc}')
## delete_dns_record
edit_rec=$(curl -s -X POST $HostWindsAPI \
-H "Content-Type: application/json" \
--data "$curl_data" \
| jq . )
echo Results: ${edit_rec[*]}