Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
cd79b034
Commit
cd79b034
authored
Nov 18, 2016
by
neilpang
Browse files
Merge branch 'dev' of
https://github.com/Neilpang/acme.sh
into dev
parents
88a8d7d9
abba00d5
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_pdns.sh
View file @
cd79b034
...
...
@@ -12,6 +12,8 @@ DEFAULT_PDNS_TTL=60
######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "123456789ABCDEF0000000000000000000000000000000000000"
#fulldomain
#txtvalue
dns_pdns_add
()
{
fulldomain
=
$1
txtvalue
=
$2
...
...
@@ -50,7 +52,7 @@ dns_pdns_add() {
_saveaccountconf PDNS_Ttl
"
$PDNS_Ttl
"
fi
_debug
"
First d
etect
the
root zone"
_debug
"
D
etect root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
...
...
@@ -68,6 +70,18 @@ dns_pdns_add() {
dns_pdns_rm
()
{
fulldomain
=
$1
_debug
"Detect root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug _domain
"
$_domain
"
if
!
rm_record
"
$_domain
"
"
$fulldomain
"
;
then
return
1
fi
return
0
}
set_record
()
{
...
...
@@ -76,14 +90,43 @@ set_record() {
full
=
$2
txtvalue
=
$3
if
!
_pdns_rest
"PATCH"
"/api/v1/servers/
$PDNS_ServerId
/zones/
$root
."
"{
\"
rrsets
\"
: [{
\"
name
\"
:
\"
$full
.
\"
,
\"
changetype
\"
:
\"
REPLACE
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
ttl
\"
:
$PDNS_Ttl
,
\"
records
\"
: [{
\"
name
\"
:
\"
$full
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
:
\"\\\"
$txtvalue
\\\"\"
,
\"
disabled
\"
: false,
\"
ttl
\"
:
$PDNS_Ttl
}]}]}"
;
then
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
_err
"Set txt record error."
return
1
fi
if
!
notify_slaves
"
$root
"
;
then
return
1
fi
return
0
}
rm_record
()
{
_info
"Remove record"
root
=
$1
full
=
$2
if
!
_pdns_rest
"PATCH"
"/api/v1/servers/
$PDNS_ServerId
/zones/
$root
."
"{
\"
rrsets
\"
: [{
\"
changetype
\"
:
\"
DELETE
\"
,
\"
name
\"
:
\"
$full
.
\"
,
\"
type
\"
:
\"
TXT
\"
}]}"
;
then
_err
"Delete txt record error."
return
1
fi
if
!
notify_slaves
"
$root
"
;
then
return
1
fi
return
0
}
notify_slaves
()
{
root
=
$1
if
!
_pdns_rest
"PUT"
"/api/v1/servers/
$PDNS_ServerId
/zones/
$root
./notify"
;
then
_err
"Notify s
er
ve
r
s error."
_err
"Notify s
la
ves error."
return
1
fi
return
0
}
...
...
@@ -113,6 +156,7 @@ _get_root() {
i
=
$(
_math
$i
+ 1
)
done
_debug
"
$domain
not found"
return
1
}
...
...
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