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
5254f300
Commit
5254f300
authored
Dec 06, 2016
by
neil
Committed by
GitHub
Dec 06, 2016
Browse files
Merge pull request #447 from Neilpang/dev
Dev
parents
bbc378ed
c0d0100c
Changes
3
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
5254f300
...
@@ -1991,7 +1991,8 @@ _clearupdns() {
...
@@ -1991,7 +1991,8 @@ _clearupdns() {
keyauthorization=$(echo "$ventry" | cut -d "$sep" -f 2)
keyauthorization=$(echo "$ventry" | cut -d "$sep" -f 2)
vtype=$(echo "$ventry" | cut -d "$sep" -f 4)
vtype=$(echo "$ventry" | cut -d "$sep" -f 4)
_currentRoot=$(echo "$ventry" | cut -d "$sep" -f 5)
_currentRoot=$(echo "$ventry" | cut -d "$sep" -f 5)
txt="$(printf "%s" "$keyauthorization" | _digest "sha256" | _urlencode)"
_debug txt "$txt"
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
_info "$d is already verified, skip $vtype."
_info "$d is already verified, skip $vtype."
continue
continue
...
@@ -2024,7 +2025,7 @@ _clearupdns() {
...
@@ -2024,7 +2025,7 @@ _clearupdns() {
txtdomain="_acme-challenge.$d"
txtdomain="_acme-challenge.$d"
if
!
$rmcommand
"
$txtdomain
"
;
then
if ! $rmcommand "$txtdomain"
"$txt"
; then
_err "Error removing txt for domain:$txtdomain"
_err "Error removing txt for domain:$txtdomain"
return 1
return 1
fi
fi
...
...
dnsapi/dns_cf.sh
View file @
5254f300
...
@@ -55,9 +55,7 @@ dns_cf_add() {
...
@@ -55,9 +55,7 @@ dns_cf_add() {
_info
"Adding record"
_info
"Adding record"
if
_cf_rest POST
"zones/
$_domain_id
/dns_records"
"{
\"
type
\"
:
\"
TXT
\"
,
\"
name
\"
:
\"
$fulldomain
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:120}"
;
then
if
_cf_rest POST
"zones/
$_domain_id
/dns_records"
"{
\"
type
\"
:
\"
TXT
\"
,
\"
name
\"
:
\"
$fulldomain
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:120}"
;
then
if
printf
--
"%s"
"
$response
"
|
grep
"
$fulldomain
"
>
/dev/null
;
then
if
printf
--
"%s"
"
$response
"
|
grep
"
$fulldomain
"
>
/dev/null
;
then
_info
"Added, sleeping 10 seconds"
_info
"Added, OK"
sleep
10
#todo: check if the record takes effect
return
0
return
0
else
else
_err
"Add txt record error."
_err
"Add txt record error."
...
@@ -83,9 +81,44 @@ dns_cf_add() {
...
@@ -83,9 +81,44 @@ dns_cf_add() {
}
}
#fulldomain
#fulldomain
txtvalue
dns_cf_rm
()
{
dns_cf_rm
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug _domain_id
"
$_domain_id
"
_debug _sub_domain
"
$_sub_domain
"
_debug _domain
"
$_domain
"
_debug
"Getting txt records"
_cf_rest GET
"zones/
${
_domain_id
}
/dns_records?type=TXT&name=
$fulldomain
&content=
$txtvalue
"
if
!
printf
"%s"
"
$response
"
|
grep
\"
success
\"
:true
>
/dev/null
;
then
_err
"Error"
return
1
fi
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
count
\"
:[^,]*"
|
cut
-d
:
-f
2
)
_debug count
"
$count
"
if
[
"
$count
"
=
"0"
]
;
then
_info
"Don't need to remove."
else
record_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
|
head
-n
1
)
_debug
"record_id"
"
$record_id
"
if
[
-z
"
$record_id
"
]
;
then
_err
"Can not get record id to remove."
return
1
fi
if
!
_cf_rest DELETE
"zones/
$_domain_id
/dns_records/
$record_id
"
;
then
_err
"Delete record error."
return
1
fi
_contains
"
$response
"
'"success":true'
fi
}
}
...
@@ -135,7 +168,7 @@ _cf_rest() {
...
@@ -135,7 +168,7 @@ _cf_rest() {
_H2
=
"X-Auth-Key:
$CF_Key
"
_H2
=
"X-Auth-Key:
$CF_Key
"
_H3
=
"Content-Type: application/json"
_H3
=
"Content-Type: application/json"
if
[
"
$
data
"
]
;
then
if
[
"
$
m
"
!=
"GET
"
]
;
then
_debug data
"
$data
"
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$CF_Api
/
$ep
"
""
"
$m
"
)
"
response
=
"
$(
_post
"
$data
"
"
$CF_Api
/
$ep
"
""
"
$m
"
)
"
else
else
...
...
dnsapi/dns_myapi.sh
View file @
5254f300
...
@@ -22,11 +22,14 @@ dns_myapi_add() {
...
@@ -22,11 +22,14 @@ dns_myapi_add() {
return
1
return
1
}
}
#Usage: fulldomain
#Usage: fulldomain
txtvalue
#Remove the txt record afer validation.
#Remove the txt record afer validation.
dns_myapi_rm
()
{
dns_myapi_rm
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
_info
"Using myapi"
_debug fulldomain
"
$fulldomain
"
_debug txtvalue
"
$txtvalue
"
}
}
#################### Private functions bellow ##################################
#################### Private functions bellow ##################################
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