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
1fff0e55
Commit
1fff0e55
authored
Mar 02, 2017
by
neil
Committed by
GitHub
Mar 02, 2017
Browse files
Merge pull request #686 from justmwa/master
Adding delete support for DNSMadeEasy and LUA API
parents
839f18d0
8d53ec53
Changes
2
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_lua.sh
View file @
1fff0e55
...
...
@@ -81,7 +81,36 @@ dns_lua_add() {
#fulldomain
dns_lua_rm
()
{
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"
_LUA_rest GET
"zones/
${
_domain_id
}
/records"
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
"
|
wc
-l
|
tr
-d
" "
)
_debug count
"
$count
"
if
[
"
$count
"
=
"0"
]
;
then
_info
"Don't need to remove."
else
record_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:[^,]*,
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
"
| _head_n 1 |
cut
-d
:
-f2
|
cut
-d
,
-f1
)
_debug
"record_id"
"
$record_id
"
if
[
-z
"
$record_id
"
]
;
then
_err
"Can not get record id to remove."
return
1
fi
if
!
_LUA_rest DELETE
"/zones/
$_domain_id
/records/
$record_id
"
;
then
_err
"Delete record error."
return
1
fi
_contains
"
$response
"
"
$record_id
"
fi
}
#################### Private functions below ##################################
...
...
@@ -129,7 +158,7 @@ _LUA_rest() {
export
_H1
=
"Accept: application/json"
export
_H2
=
"Authorization: Basic
$LUA_auth
"
if
[
"
$
data
"
]
;
then
if
[
"
$
m
"
!=
"GET
"
]
;
then
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$LUA_Api
/
$ep
"
""
"
$m
"
)
"
else
...
...
dnsapi/dns_me.sh
100755 → 100644
View file @
1fff0e55
...
...
@@ -78,7 +78,36 @@ dns_me_add() {
#fulldomain
dns_me_rm
()
{
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"
_me_rest GET
"
${
_domain_id
}
/records?recordName=
$_sub_domain
&type=TXT"
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
totalRecords
\"
:[^,]*"
|
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 |
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
!
_me_rest DELETE
"
$_domain_id
/records/
$record_id
"
;
then
_err
"Delete record error."
return
1
fi
_contains
"
$response
"
''
fi
}
#################### Private functions below ##################################
...
...
@@ -130,7 +159,7 @@ _me_rest() {
export
_H2
=
"x-dnsme-requestDate:
$cdate
"
export
_H3
=
"x-dnsme-hmac:
$hmac
"
if
[
"
$
data
"
]
;
then
if
[
"
$
m
"
!=
"GET
"
]
;
then
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$ME_Api
/
$ep
"
""
"
$m
"
)
"
else
...
...
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