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
b7b4ae42
Commit
b7b4ae42
authored
Feb 22, 2020
by
David Kerr
Browse files
Merge branch 'dev' of
https://github.com/acmesh-official/acme.sh
into ssh-deploy
parents
c7068171
b73b0787
Changes
3
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_linode_v4.sh
View file @
b7b4ae42
...
@@ -36,7 +36,7 @@ dns_linode_v4_add() {
...
@@ -36,7 +36,7 @@ dns_linode_v4_add() {
}"
}"
if
_rest POST
"/
$_domain_id
/records"
"
$_payload
"
&&
[
-n
"
$response
"
]
;
then
if
_rest POST
"/
$_domain_id
/records"
"
$_payload
"
&&
[
-n
"
$response
"
]
;
then
_resource_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:
\s
*[0-9]+"
|
cut
-d
:
-f
2 |
tr
-d
" "
| _head_n 1
)
_resource_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:
*[0-9]+"
|
cut
-d
:
-f
2 |
tr
-d
" "
| _head_n 1
)
_debug _resource_id
"
$_resource_id
"
_debug _resource_id
"
$_resource_id
"
if
[
-z
"
$_resource_id
"
]
;
then
if
[
-z
"
$_resource_id
"
]
;
then
...
@@ -74,9 +74,9 @@ dns_linode_v4_rm() {
...
@@ -74,9 +74,9 @@ dns_linode_v4_rm() {
if
_rest GET
"/
$_domain_id
/records"
&&
[
-n
"
$response
"
]
;
then
if
_rest GET
"/
$_domain_id
/records"
&&
[
-n
"
$response
"
]
;
then
response
=
"
$(
echo
"
$response
"
|
tr
-d
"
\n
"
|
tr
'{'
"|"
|
sed
's/|/&{/g'
|
tr
"|"
"
\n
"
)
"
response
=
"
$(
echo
"
$response
"
|
tr
-d
"
\n
"
|
tr
'{'
"|"
|
sed
's/|/&{/g'
|
tr
"|"
"
\n
"
)
"
resource
=
"
$(
echo
"
$response
"
| _egrep_o
"{.*
\"
name
\"
:
\s
*
\"
$_sub_domain
\"
.*}"
)
"
resource
=
"
$(
echo
"
$response
"
| _egrep_o
"
\
{
.*
\"
name
\"
:
*
\"
$_sub_domain
\"
.*}"
)
"
if
[
"
$resource
"
]
;
then
if
[
"
$resource
"
]
;
then
_resource_id
=
$(
printf
"%s
\n
"
"
$resource
"
| _egrep_o
"
\"
id
\"
:
\s
*[0-9]+"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
\
)
_resource_id
=
$(
printf
"%s
\n
"
"
$resource
"
| _egrep_o
"
\"
id
\"
:
*[0-9]+"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
\
)
if
[
"
$_resource_id
"
]
;
then
if
[
"
$_resource_id
"
]
;
then
_debug _resource_id
"
$_resource_id
"
_debug _resource_id
"
$_resource_id
"
...
@@ -139,9 +139,9 @@ _get_root() {
...
@@ -139,9 +139,9 @@ _get_root() {
return
1
return
1
fi
fi
hostedzone
=
"
$(
echo
"
$response
"
| _egrep_o
"{.*
\"
domain
\"
:
\s
*
\"
$h
\"
.*}"
)
"
hostedzone
=
"
$(
echo
"
$response
"
| _egrep_o
"
\
{
.*
\"
domain
\"
:
*
\"
$h
\"
.*}"
)
"
if
[
"
$hostedzone
"
]
;
then
if
[
"
$hostedzone
"
]
;
then
_domain_id
=
$(
printf
"%s
\n
"
"
$hostedzone
"
| _egrep_o
"
\"
id
\"
:
\s
*[0-9]+"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
\
)
_domain_id
=
$(
printf
"%s
\n
"
"
$hostedzone
"
| _egrep_o
"
\"
id
\"
:
*[0-9]+"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
\
)
if
[
"
$_domain_id
"
]
;
then
if
[
"
$_domain_id
"
]
;
then
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_domain
=
$h
_domain
=
$h
...
...
dnsapi/dns_yandex.sh
View file @
b7b4ae42
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
# Values to export:
# Values to export:
# export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# export PDD_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Sometimes cloudflare / google doesn't pick new dns records fast enough.
# 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"
...
@@ -13,97 +16,106 @@ dns_yandex_add() {
...
@@ -13,97 +16,106 @@ dns_yandex_add() {
fulldomain
=
"
${
1
}
"
fulldomain
=
"
${
1
}
"
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
export
_H1
=
"PddToken:
$PDD_Token
"
_PDD_get_domain
"
$fulldomain
"
||
return
1
_PDD_get_domain
||
return
1
_debug
"Found suitable domain in pdd:
$curDomain
"
_debug
"Found suitable domain:
$domain
"
curData
=
"domain=
${
curDomain
}
&type=TXT&subdomain=
${
curSubdomain
}
&ttl=360&content=
${
txtvalue
}
"
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/add"
_PDD_get_record_ids
||
return
1
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
curUri
}
"
)
"
_debug
"Record_ids:
$record_ids
"
_debug
"Result:
$curResult
"
if
[
!
-z
"
$record_ids
"
]
;
then
_info
"All existing
$subdomain
records from
$domain
will be removed at the very end."
fi
data
=
"domain=
${
domain
}
&type=TXT&subdomain=
${
subdomain
}
&ttl=300&content=
${
txtvalue
}
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/add"
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
if
_contains
"
$result
"
'"success":"error"'
&&
_contains
"
$result
"
'"error":"record_exists"'
;
then
_info
"Record already exists."
else
_err
"Can't add
$subdomain
to
$domain
."
return
1
fi
fi
}
}
#Usage: dns_myapi_rm _acme-challenge.www.domain.com
#Usage: dns_myapi_rm _acme-challenge.www.domain.com
dns_yandex_rm
()
{
dns_yandex_rm
()
{
fulldomain
=
"
${
1
}
"
fulldomain
=
"
${
1
}
"
_debug
"Calling: dns_yandex_rm() '
${
fulldomain
}
'"
_debug
"Calling: dns_yandex_rm() '
${
fulldomain
}
'"
_PDD_credentials
||
return
1
_PDD_credentials
||
return
1
export
_H1
=
"PddToken:
$PDD_Token
"
_PDD_get_domain
"
$fulldomain
"
||
return
1
_PDD_get_domain
"
$fulldomain
"
||
return
1
_debug
"Found suitable domain
in pdd:
$curD
omain
"
_debug
"Found suitable domain
:
$d
omain
"
record_id
=
$(
pdd
_get_record_id
"
${
fulldomain
}
"
)
_PDD
_get_record_id
s
"
${
domain
}
"
"
${
subdomain
}
"
||
return
1
_debug
"Re
sult
:
$record_id
"
_debug
"Re
cord_ids
:
$record_id
s
"
for
rec_i
in
$record_id
;
do
for
record_id
in
$record_ids
;
do
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/del"
data
=
"domain=
${
domain
}
&record_id=
${
record_id
}
"
curData
=
"domain=
${
curDomain
}
&record_id=
${
rec_i
}
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/del"
curResult
=
"
$(
_post
"
${
curData
}
"
"
${
curUri
}
"
)
"
result
=
"
$(
_post
"
${
data
}
"
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$curResult
"
_debug
"Result:
$result
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
_info
"Can't remove
$subdomain
from
$domain
."
fi
done
done
}
}
#################### Private functions below ##################################
#################### Private functions below ##################################
_PDD_get_domain
()
{
_PDD_get_domain
()
{
fulldomain
=
"
${
1
}
"
subdomain_start
=
1
__page
=
1
while
true
;
do
__last
=
0
domain_start
=
$(
_math
$subdomain_start
+ 1
)
while
[
$__last
-eq
0
]
;
do
domain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
"
$domain_start
"
-
)
uri1
=
"https://pddimp.yandex.ru/api2/admin/domain/domains?page=
${
__page
}
&on_page=20"
subdomain
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
-
"
$subdomain_start
"
)
res1
=
"
$(
_get
"
$uri1
"
| _normalizeJson
)
"
_debug2
"res1"
"
$res1
"
_debug
"Checking domain
$domain
"
__found
=
"
$(
echo
"
$res1
"
|
sed
-n
-e
's#.* "found": \([^,]*\),.*#\1#p'
)
"
if
[
-z
"
$domain
"
]
;
then
_debug
"found:
$__found
results on page"
return
1
if
[
"0
$__found
"
-lt
20
]
;
then
_debug
"last page:
$__page
"
__last
=
1
fi
fi
__all_domains
=
"
$__all_domains
$(
echo
"
$res1
"
|
tr
","
"
\n
"
|
grep
'"name"'
|
cut
-d
:
-f2
|
sed
-e
's@"@@g'
)
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
$domain
"
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
__page
=
$(
_math
$__page
+ 1
)
if
_contains
"
$result
"
'"success":"ok"'
;
then
done
return
0
fi
k
=
2
subdomain_start
=
$(
_math
$subdomain_start
+ 1
)
while
[
$k
-lt
10
]
;
do
__t
=
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
$k
-100
)
_debug
"finding zone for domain
$__t
"
for
d
in
$__all_domains
;
do
if
[
"
$d
"
=
"
$__t
"
]
;
then
p
=
$(
_math
$k
- 1
)
curSubdomain
=
"
$(
echo
"
$fulldomain
"
|
cut
-d
.
-f
"1-
$p
"
)
"
curDomain
=
"
$__t
"
return
0
fi
done
k
=
$(
_math
$k
+ 1
)
done
done
_err
"No suitable domain found in your account"
return
1
}
}
_PDD_credentials
()
{
_PDD_credentials
()
{
if
[
-z
"
${
PDD_Token
}
"
]
;
then
if
[
-z
"
${
PDD_Token
}
"
]
;
then
PDD_Token
=
""
PDD_Token
=
""
_err
"You need to export PDD_Token=xxxxxxxxxxxxxxxxx"
_err
"You need to export PDD_Token=xxxxxxxxxxxxxxxxx
.
"
_err
"You can get it at https://pddimp.yandex.ru/api2/admin/get_token"
_err
"You can get it at https://pddimp.yandex.ru/api2/admin/get_token
.
"
return
1
return
1
else
else
_saveaccountconf PDD_Token
"
${
PDD_Token
}
"
_saveaccountconf PDD_Token
"
${
PDD_Token
}
"
fi
fi
export
_H1
=
"PddToken:
$PDD_Token
"
}
}
pdd_get_record_id
()
{
_PDD_get_record_ids
()
{
fulldomain
=
"
${
1
}
"
_debug
"Check existing records for
$subdomain
"
uri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
${
domain
}
"
result
=
"
$(
_get
"
${
uri
}
"
| _normalizeJson
)
"
_debug
"Result:
$result
"
_PDD_get_domain
"
$fulldomain
"
if
!
_contains
"
$result
"
'"success":"ok"'
;
then
_debug
"Found suitable domain in pdd:
$curDomain
"
return
1
fi
curUri
=
"https://pddimp.yandex.ru/api2/admin/dns/list?domain=
${
curDomain
}
"
record_ids
=
$(
echo
"
$result
"
| _egrep_o
"{[^{]*
\"
subdomain
\"
:
\"
${
subdomain
}
\"
[^}]*}"
|
sed
-n
-e
's#.*"record_id": \([0-9]*\).*#\1#p'
)
curResult
=
"
$(
_get
"
${
curUri
}
"
| _normalizeJson
)
"
_debug
"Result:
$curResult
"
echo
"
$curResult
"
| _egrep_o
"{[^{]*
\"
content
\"
:[^{]*
\"
subdomain
\"
:
\"
${
curSubdomain
}
\"
"
|
sed
-n
-e
's#.* "record_id": \(.*\),[^,]*#\1#p'
}
}
notify/cqhttp.sh
0 → 100644
View file @
b7b4ae42
#!/usr/bin/env sh
#Support for CQHTTP api. Push notification on CoolQ
#CQHTTP_TOKEN="" Recommended to be not empty, QQ application token
#CQHTTP_USER="" Required, QQ receiver ID
#CQHTTP_APIROOT="" Required, CQHTTP Server URL (without slash suffix)
#CQHTTP_CUSTOM_MSGHEAD="" Optional, custom message header
CQHTTP_APIPATH
=
"/send_private_msg"
cqhttp_send
()
{
_subject
=
"
$1
"
_content
=
"
$2
"
_statusCode
=
"
$3
"
#0: success, 1: error 2($RENEW_SKIP): skipped
_debug
"_statusCode"
"
$_statusCode
"
CQHTTP_TOKEN
=
"
${
CQHTTP_TOKEN
:-
$(
_readaccountconf_mutable CQHTTP_TOKEN
)
}
"
if
[
-z
"
$CQHTTP_TOKEN
"
]
;
then
CQHTTP_TOKEN
=
""
_info
"You didn't specify a CQHTTP application token yet, which is unsafe. Assuming it to be empty."
else
_saveaccountconf_mutable CQHTTP_TOKEN
"
$CQHTTP_TOKEN
"
fi
CQHTTP_USER
=
"
${
CQHTTP_USER
:-
$(
_readaccountconf_mutable CQHTTP_USER
)
}
"
if
[
-z
"
$CQHTTP_USER
"
]
;
then
CQHTTP_USER
=
""
_err
"You didn't specify a QQ user yet."
return
1
fi
_saveaccountconf_mutable CQHTTP_USER
"
$CQHTTP_USER
"
CQHTTP_APIROOT
=
"
${
CQHTTP_APIROOT
:-
$(
_readaccountconf_mutable CQHTTP_APIROOT
)
}
"
if
[
-z
"
$CQHTTP_APIROOT
"
]
;
then
CQHTTP_APIROOT
=
""
_err
"You didn't specify the API root yet."
return
1
fi
_saveaccountconf_mutable CQHTTP_APIROOT
"
$CQHTTP_APIROOT
"
CQHTTP_CUSTOM_MSGHEAD
=
"
${
CQHTTP_CUSTOM_MSGHEAD
:-
$(
_readaccountconf_mutable CQHTTP_CUSTOM_MSGHEAD
)
}
"
if
[
-z
"
$CQHTTP_CUSTOM_MSGHEAD
"
]
;
then
CQHTTP_CUSTOM_MSGHEAD
=
"A message from acme.sh:"
else
_saveaccountconf_mutable CQHTTP_CUSTOM_MSGHEAD
"
$CQHTTP_CUSTOM_MSGHEAD
"
fi
_access_token
=
"
$(
printf
"%s"
"
$CQHTTP_TOKEN
"
| _url_encode
)
"
_user_id
=
"
$(
printf
"%s"
"
$CQHTTP_USER
"
| _url_encode
)
"
_message
=
"
$(
printf
"
$CQHTTP_CUSTOM_MSGHEAD
%s
\\
n%s"
"
$_subject
"
"
$_content
"
| _url_encode
)
"
_finalUrl
=
"
$CQHTTP_APIROOT$CQHTTP_APIPATH
?access_token=
$_access_token
&user_id=
$_user_id
&message=
$_message
"
response
=
"
$(
_get
"
$_finalUrl
"
)
"
if
[
"
$?
"
=
"0"
]
&&
_contains
"
$response
"
"
\"
retcode
\"
:0,
\"
status
\"
:
\"
ok
\"
"
;
then
_info
"QQ send success."
return
0
fi
_err
"QQ send error."
_debug
"URL"
"
$_finalUrl
"
_debug
"Response"
"
$response
"
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