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
ef7b51be
Commit
ef7b51be
authored
Jan 12, 2020
by
Nick Stepa
Browse files
Remove local keyword.
parent
8494ac8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_yandex.sh
View file @
ef7b51be
...
@@ -6,15 +6,15 @@
...
@@ -6,15 +6,15 @@
# Values to export:
# Values to export:
# export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Sometimes cloudflare / google doesn't pick new dns recods fast enough.
# Sometimes cloudflare / google doesn't pick new dns reco
r
ds fast enough.
# You can add --dnssleep XX to params as workaround.
# You can add --dnssleep XX to params as workaround.
######## Public functions #####################
######## Public functions #####################
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_yandex_add
()
{
dns_yandex_add
()
{
local
fulldomain
=
"
${
1
}
"
fulldomain
=
"
${
1
}
"
local
txtvalue
=
"
${
2
}
"
txtvalue
=
"
${
2
}
"
_debug
"Calling: dns_yandex_add() '
${
fulldomain
}
' '
$txtvalue
'"
_debug
"Calling: dns_yandex_add() '
${
fulldomain
}
' '
$txtvalue
'"
_PDD_credentials
||
return
1
_PDD_credentials
||
return
1
...
@@ -30,9 +30,9 @@ dns_yandex_add() {
...
@@ -30,9 +30,9 @@ dns_yandex_add() {
return
1
return
1
fi
fi
local
data
=
"domain=
${
domain
}
&type=TXT&subdomain=
${
subdomain
}
&ttl=300&content=
${
txtvalue
}
"
data
=
"domain=
${
domain
}
&type=TXT&subdomain=
${
subdomain
}
&ttl=300&content=
${
txtvalue
}
"
local
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/add"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/add"
local
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
_debug
"Result:
$result
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
...
@@ -43,7 +43,7 @@ dns_yandex_add() {
...
@@ -43,7 +43,7 @@ dns_yandex_add() {
#Usage: dns_myapi_rm _acme-challenge.www.domain.com
#Usage: dns_myapi_rm _acme-challenge.www.domain.com
dns_yandex_rm
()
{
dns_yandex_rm
()
{
local
fulldomain
=
"
${
1
}
"
fulldomain
=
"
${
1
}
"
_debug
"Calling: dns_yandex_rm() '
${
fulldomain
}
'"
_debug
"Calling: dns_yandex_rm() '
${
fulldomain
}
'"
_PDD_credentials
||
return
1
_PDD_credentials
||
return
1
...
@@ -55,9 +55,9 @@ dns_yandex_rm() {
...
@@ -55,9 +55,9 @@ dns_yandex_rm() {
_debug
"Record_ids:
$record_ids
"
_debug
"Record_ids:
$record_ids
"
for
record_id
in
$record_ids
;
do
for
record_id
in
$record_ids
;
do
local
data
=
"domain=
${
domain
}
&record_id=
${
record_id
}
"
data
=
"domain=
${
domain
}
&record_id=
${
record_id
}
"
local
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/del"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/del"
local
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
_debug
"Result:
$result
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
...
@@ -69,21 +69,21 @@ dns_yandex_rm() {
...
@@ -69,21 +69,21 @@ dns_yandex_rm() {
#################### Private functions below ##################################
#################### Private functions below ##################################
_PDD_get_domain
()
{
_PDD_get_domain
()
{
local
fulldomain
=
${
1
}
fulldomain
=
${
1
}
local
subdomain_start
=
1
subdomain_start
=
1
while
true
;
do
while
true
;
do
local
domain_start
=
$(
_math
$subdomain_start
+ 1
)
domain_start
=
$(
_math
$subdomain_start
+ 1
)
domain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
$domain_start
-
)
domain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
"
$domain_start
"
-
)
subdomain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
-
$subdomain_start
)
subdomain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
-
"
$subdomain_start
"
)
_debug
"Checking domain
$domain
"
_debug
"Checking domain
$domain
"
if
[
-z
"
$domain
"
]
;
then
if
[
-z
"
$domain
"
]
;
then
return
1
return
1
fi
fi
local
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
$domain
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
$domain
"
local
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
_debug
"Result:
$result
"
if
_contains
"
$result
"
'"success":"ok"'
;
then
if
_contains
"
$result
"
'"success":"ok"'
;
then
...
@@ -106,13 +106,13 @@ _PDD_credentials() {
...
@@ -106,13 +106,13 @@ _PDD_credentials() {
}
}
_PDD_get_record_ids
()
{
_PDD_get_record_ids
()
{
local
domain
=
"
${
1
}
"
domain
=
"
${
1
}
"
local
subdomain
=
"
${
2
}
"
subdomain
=
"
${
2
}
"
_debug
"Check existing records for
$subdomain
"
_debug
"Check existing records for
$subdomain
"
local
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
${
domain
}
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
${
domain
}
"
local
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
_debug
"Result:
$result
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
...
...
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