Browse Source
Modified DNSAPI for PowerDNS to support wildcard certificates
pull/1429/head
Nils Sandmann
7 years ago
No known key found for this signature in database
GPG Key ID: 605B8EC396A1D3B9
1 changed files with
17 additions and
2 deletions
-
dnsapi/dns_pdns.sh
|
@ -88,9 +88,20 @@ set_record() { |
|
|
_info "Adding record" |
|
|
_info "Adding record" |
|
|
root=$1 |
|
|
root=$1 |
|
|
full=$2 |
|
|
full=$2 |
|
|
txtvalue=$3 |
|
|
|
|
|
|
|
|
new_challenge=$3 |
|
|
|
|
|
|
|
|
if ! _pdns_rest "PATCH" "/api/v1/servers/$PDNS_ServerId/zones/$root" "{\"rrsets\": [{\"changetype\": \"REPLACE\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $PDNS_Ttl, \"records\": [{\"name\": \"$full.\", \"type\": \"TXT\", \"content\": \"\\\"$txtvalue\\\"\", \"disabled\": false, \"ttl\": $PDNS_Ttl}]}]}"; then |
|
|
|
|
|
|
|
|
_pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones/$root" |
|
|
|
|
|
_existing_challenges=($(echo "$response" | _normalizeJson | grep -Po "\"name\":\"$fulldomain\K.*?}]" | grep -Po 'content\":\"\\"\K[^\\]*')) |
|
|
|
|
|
_record_string="" |
|
|
|
|
|
_build_record_string $new_challenge |
|
|
|
|
|
|
|
|
|
|
|
for i in "${_existing_challenges[@]}" |
|
|
|
|
|
do |
|
|
|
|
|
_record_string+=", " |
|
|
|
|
|
_build_record_string $i |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
if ! _pdns_rest "PATCH" "/api/v1/servers/$PDNS_ServerId/zones/$root" "{\"rrsets\": [{\"changetype\": \"REPLACE\", \"name\": \"$full.\", \"type\": \"TXT\", \"ttl\": $PDNS_Ttl, \"records\": [$_record_string]}]}"; then |
|
|
_err "Set txt record error." |
|
|
_err "Set txt record error." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
@ -185,3 +196,7 @@ _pdns_rest() { |
|
|
|
|
|
|
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_build_record_string() { |
|
|
|
|
|
_record_string+="{\"content\": \"\\\"$1\\\"\", \"disabled\": false}" |
|
|
|
|
|
} |