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
a460ac02
Commit
a460ac02
authored
Jul 08, 2017
by
Vladimir Berezhnoy
Browse files
add pdd.yandex.ru dns api
parent
accbda9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_yandex.sh
0 → 100755
View file @
a460ac02
#!/usr/bin/env sh
# Author: non7top@gmail.com
# 07 Jul 2017
# report bugs at https://github.com/non7top/acme.sh
# Values to export:
# export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
######## Public functions #####################
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_yandex_add
()
{
fulldomain
=
"
${
1
}
"
txtvalue
=
"
${
2
}
"
_debug
"Calling: dns_yandex_add() '
${
fulldomain
}
' '
${
txtvalue
}
'"
_PDD_credentials
export
_H1
=
"PddToken:
$PDD_Token
"
curDomain
=
"
$(
echo
${
fulldomain
}
|awk
-F
.
'{printf("%s.%s\n",$(NF-1), $NF)}'
)
"
curSubdomain
=
"
$(
echo
${
fulldomain
}
|
sed
-e
's#$curDomain##'
)
"
curData
=
"domain=
${
curDomain
}
&type=TXT&subdomain=
${
curSubdomain
}
&ttl=360&content=
${
txtvalue
}
"
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/add"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
curUri
}
"
)
"
_debug
"Result:
$curResult
"
}
#Usage: dns_myapi_rm _acme-challenge.www.domain.com
dns_yandex_rm
()
{
fulldomain
=
"
${
1
}
"
_debug
"Calling: dns_yandex_rm() '
${
fulldomain
}
'"
_PDD_credentials
export
_H1
=
"PddToken:
$PDD_Token
"
local
record_id
=
$(
pdd_get_record_id
${
fulldomain
}
)
curDomain
=
"
$(
echo
${
fulldomain
}
|awk
-F
.
'{printf("%s.%s\n",$(NF-1), $NF)}'
)
"
curSubdomain
=
"
$(
echo
${
fulldomain
}
|
sed
-e
's#$curDomain##'
)
"
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/del"
curData
=
"domain=
${
curDomain
}
&record_id=
${
record_id
}
"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
curUri
}
"
)
"
_debug
"Result:
$curResult
"
}
#################### Private functions below ##################################
_PDD_credentials
()
{
if
[
-z
"
${
PDD_Token
}
"
]
;
then
PDD_Token
=
""
_err
"You haven't specified the ISPConfig Login data."
return
1
else
_saveaccountconf PDD_Token
"
${
PDD_Token
}
"
fi
}
pdd_get_record_id
()
{
local
fulldomain
=
"
${
1
}
"
local
curDomain
=
"
$(
echo
${
fulldomain
}
|awk
-F
.
'{printf("%s.%s\n",$(NF-1), $NF)}'
)
"
local
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
${
curDomain
}
"
local
curResult
=
"
$(
_get
"
${
curUri
}
"
)
"
echo
${
curResult
}
|
\
python
-c
'
import sys, json;
rs=json.load(sys.stdin)["records"]
for r in rs:
if r["fqdn"]=="${fulldomain}":
print r["record_id"]
exit
'
}
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