]>
git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_yandex.sh
2 # Author: non7top@gmail.com
4 # report bugs at https://github.com/non7top/acme.sh
7 # export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
9 ######## Public functions #####################
11 #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
15 _debug
"Calling: dns_yandex_add() '${fulldomain}' '${txtvalue}'"
16 _PDD_credentials ||
return 1
17 export _H1
="PddToken: $PDD_Token"
19 _PDD_get_domain
"$fulldomain" ||
return 1
20 _debug
"Found suitable domain in pdd: $curDomain"
21 curData
="domain=${curDomain}&type=TXT&subdomain=${curSubdomain}&ttl=360&content=${txtvalue}"
22 curUri
="https://pddimp.yandex.ru/api2/admin/dns/add"
23 curResult
="$(_post "${curData}" "${curUri}")"
24 _debug
"Result: $curResult"
27 #Usage: dns_myapi_rm _acme-challenge.www.domain.com
30 _debug
"Calling: dns_yandex_rm() '${fulldomain}'"
31 _PDD_credentials ||
return 1
32 export _H1
="PddToken: $PDD_Token"
34 _PDD_get_domain
"$fulldomain" ||
return 1
35 _debug
"Found suitable domain in pdd: $curDomain"
37 record_id
=$
(pdd_get_record_id
"${fulldomain}")
38 _debug
"Result: $record_id"
40 for rec_i
in $record_id; do
41 curUri
="https://pddimp.yandex.ru/api2/admin/dns/del"
42 curData
="domain=${curDomain}&record_id=${rec_i}"
43 curResult
="$(_post "${curData}" "${curUri}")"
44 _debug
"Result: $curResult"
48 #################### Private functions below ##################################
54 while [ $__last -eq 0 ]; do
55 uri1
="https://pddimp.yandex.ru/api2/admin/domain/domains?page=${__page}&on_page=20"
56 res1
="$(_get "$uri1" | _normalizeJson)"
57 _debug2
"res1" "$res1"
58 __found
="$(echo "$res1" | sed -n -e 's#.* "found
": \([^,]*\),.*#\1#p')"
59 _debug
"found: $__found results on page"
60 if [ "0$__found" -lt 20 ]; then
61 _debug
"last page: $__page"
65 __all_domains
="$__all_domains $(echo "$res1" | tr "," "\n" | grep '"name
"' | cut -d: -f2 | sed -e 's@"@@g
')"
67 __page=$(_math $__page + 1)
71 while [ $k -lt 10 ]; do
72 __t=$(echo "$fulldomain" | cut -d . -f $k-100)
73 _debug "finding zone for domain $__t"
74 for d in $__all_domains; do
75 if [ "$d" = "$__t" ]; then
77 curSubdomain="$(echo "$fulldomain" | cut -d . -f "1-$p")"
84 _err "No suitable domain found in your account"
89 if [ -z "${PDD_Token}" ]; then
91 _err "You need to export PDD_Token=xxxxxxxxxxxxxxxxx"
92 _err "You can get it at https://pddimp.yandex.ru/api2/admin/get_token"
95 _saveaccountconf PDD_Token "${PDD_Token}"
102 _PDD_get_domain "$fulldomain"
103 _debug "Found suitable domain in pdd: $curDomain"
105 curUri="https://pddimp.yandex.ru/api2/admin/dns/list?domain=${curDomain}"
106 curResult="$(_get "${curUri}" | _normalizeJson)"
107 _debug "Result: $curResult"
108 echo "$curResult" | _egrep_o "{[^{]*\"content\":[^{]*\"subdomain\":\"${curSubdomain}\"" | sed -n -e 's
#.* "record_id": \(.*\),[^,]*#\1#p'