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
0096ef4d
Commit
0096ef4d
authored
Feb 15, 2018
by
neilpang
Browse files
fix ali
parent
ce6c7d4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_ali.sh
View file @
0096ef4d
...
@@ -10,6 +10,8 @@ dns_ali_add() {
...
@@ -10,6 +10,8 @@ dns_ali_add() {
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
Ali_Key
=
"
${
Ali_Key
:-
$(
_readaccountconf_mutable Ali_Key
)
}
"
Ali_Secret
=
"
${
Ali_Secret
:-
$(
_readaccountconf_mutable Ali_Secret
)
}
"
if
[
-z
"
$Ali_Key
"
]
||
[
-z
"
$Ali_Secret
"
]
;
then
if
[
-z
"
$Ali_Key
"
]
||
[
-z
"
$Ali_Secret
"
]
;
then
Ali_Key
=
""
Ali_Key
=
""
Ali_Secret
=
""
Ali_Secret
=
""
...
@@ -18,8 +20,8 @@ dns_ali_add() {
...
@@ -18,8 +20,8 @@ dns_ali_add() {
fi
fi
#save the api key and secret to the account conf file.
#save the api key and secret to the account conf file.
_saveaccountconf Ali_Key
"
$Ali_Key
"
_saveaccountconf
_mutable
Ali_Key
"
$Ali_Key
"
_saveaccountconf Ali_Secret
"
$Ali_Secret
"
_saveaccountconf
_mutable
Ali_Secret
"
$Ali_Secret
"
_debug
"First detect the root zone"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
if
!
_get_root
"
$fulldomain
"
;
then
...
@@ -32,6 +34,15 @@ dns_ali_add() {
...
@@ -32,6 +34,15 @@ dns_ali_add() {
dns_ali_rm
()
{
dns_ali_rm
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
Ali_Key
=
"
${
Ali_Key
:-
$(
_readaccountconf_mutable Ali_Key
)
}
"
Ali_Secret
=
"
${
Ali_Secret
:-
$(
_readaccountconf_mutable Ali_Secret
)
}
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
return
1
fi
_clean
_clean
}
}
...
@@ -76,16 +87,14 @@ _ali_rest() {
...
@@ -76,16 +87,14 @@ _ali_rest() {
return
1
return
1
fi
fi
_debug2 response
"
$response
"
if
[
-z
"
$2
"
]
;
then
if
[
-z
"
$2
"
]
;
then
message
=
"
$(
printf
"%s"
"
$response
"
| _egrep_o
"
\"
Message
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
)
"
message
=
"
$(
echo
"
$response
"
| _egrep_o
"
\"
Message
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
)
"
if
[
-n
"
$message
"
]
;
then
if
[
"
$message
"
]
;
then
_err
"
$message
"
_err
"
$message
"
return
1
return
1
fi
fi
fi
fi
_debug2 response
"
$response
"
return
0
}
}
_ali_urlencode
()
{
_ali_urlencode
()
{
...
@@ -112,12 +121,14 @@ _ali_nonce() {
...
@@ -112,12 +121,14 @@ _ali_nonce() {
}
}
_check_exist_query
()
{
_check_exist_query
()
{
_qdomain
=
"
$1
"
_qsubdomain
=
"
$2
"
query
=
''
query
=
''
query
=
$query
'AccessKeyId='
$Ali_Key
query
=
$query
'AccessKeyId='
$Ali_Key
query
=
$query
'&Action=DescribeDomainRecords'
query
=
$query
'&Action=DescribeDomainRecords'
query
=
$query
'&DomainName='
$
1
query
=
$query
'&DomainName='
$
_qdomain
query
=
$query
'&Format=json'
query
=
$query
'&Format=json'
query
=
$query
'&RRKeyWord=
_acme-challenge'
query
=
$query
'&RRKeyWord=
'
$_qsubdomain
query
=
$query
'&SignatureMethod=HMAC-SHA1'
query
=
$query
'&SignatureMethod=HMAC-SHA1'
query
=
$query
"&SignatureNonce=
$(
_ali_nonce
)
"
query
=
$query
"&SignatureNonce=
$(
_ali_nonce
)
"
query
=
$query
'&SignatureVersion=1.0'
query
=
$query
'&SignatureVersion=1.0'
...
@@ -169,17 +180,21 @@ _describe_records_query() {
...
@@ -169,17 +180,21 @@ _describe_records_query() {
}
}
_clean
()
{
_clean
()
{
_check_exist_query
"
$_domain
"
_check_exist_query
"
$_domain
"
"
$_sub_domain
"
if
!
_ali_rest
"Check exist records"
"ignore"
;
then
if
!
_ali_rest
"Check exist records"
"ignore"
;
then
return
1
return
1
fi
fi
records
=
"
$(
echo
"
$response
"
-n
| _egrep_o
"
\"
RecordId
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
)
"
record_id
=
"
$(
echo
"
$response
"
|
tr
'{'
"
\n
"
|
grep
"
$_sub_domain
"
|
grep
"
$txtvalue
"
|
tr
","
"
\n
"
|
grep
RecordId |
cut
-d
'"'
-f
4
)
"
printf
"%s"
"
$records
"
\
_debug2 record_id
"
$record_id
"
|
while
read
-r
record_id
;
do
_delete_record_query
"
$record_id
"
if
[
-z
"
$record_id
"
]
;
then
_ali_rest
"Delete record
$record_id
"
"ignore"
_debug
"record not found, skip"
done
else
_delete_record_query
"
$record_id
"
_ali_rest
"Delete record
$record_id
"
"ignore"
fi
}
}
_timestamp
()
{
_timestamp
()
{
...
...
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