Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
af5ff2bb
Unverified
Commit
af5ff2bb
authored
Mar 21, 2018
by
Nils Sandmann
Browse files
Modified DNSAPI for PowerDNS to support wildcard certificates
parent
46ac97a3
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_pdns.sh
View file @
af5ff2bb
...
...
@@ -88,9 +88,20 @@ set_record() {
_info
"Adding record"
root
=
$1
full
=
$2
txtvalu
e
=
$3
new_challeng
e
=
$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."
return
1
fi
...
...
@@ -185,3 +196,7 @@ _pdns_rest() {
return
0
}
_build_record_string
()
{
_record_string+
=
"{
\"
content
\"
:
\"\\\"
$1
\\\"\"
,
\"
disabled
\"
: false}"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment