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
5d833336
Commit
5d833336
authored
Jan 31, 2017
by
neilpang
Browse files
minor
parent
bb6326f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_lua.sh
View file @
5d833336
...
@@ -46,12 +46,12 @@ dns_lua_add() {
...
@@ -46,12 +46,12 @@ dns_lua_add() {
return
1
return
1
fi
fi
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
name
\"
:
\"
$fulldomain
\"
"
|
wc
-l
)
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
name
\"
:
\"
$fulldomain
\"
"
|
wc
-l
|
tr
-s
" "
)
_debug count
"
$count
"
_debug count
"
$count
"
if
[
"
$count
"
=
"0"
]
;
then
if
[
"
$count
"
=
"0"
]
;
then
_info
"Adding record"
_info
"Adding record"
if
_LUA_rest POST
"zones/
$_domain_id
/records"
"{
\"
type
\"
:
\"
TXT
\"
,
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:120}"
;
then
if
_LUA_rest POST
"zones/
$_domain_id
/records"
"{
\"
type
\"
:
\"
TXT
\"
,
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:120}"
;
then
if
printf
--
"%s"
"
$response
"
|
grep
"
$fulldomain
"
>
/dev/null
;
then
if
_contains
"
$response
"
"
$fulldomain
"
;
then
_info
"Added"
_info
"Added"
#todo: check if the record takes effect
#todo: check if the record takes effect
return
0
return
0
...
@@ -99,6 +99,7 @@ _get_root() {
...
@@ -99,6 +99,7 @@ _get_root() {
fi
fi
while
true
;
do
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
if
[
-z
"
$h
"
]
;
then
if
[
-z
"
$h
"
]
;
then
#not valid
#not valid
return
1
return
1
...
@@ -106,6 +107,7 @@ _get_root() {
...
@@ -106,6 +107,7 @@ _get_root() {
if
_contains
"
$response
"
"
\"
name
\"
:
\"
$h
\"
"
;
then
if
_contains
"
$response
"
"
\"
name
\"
:
\"
$h
\"
"
;
then
_domain_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:[^,]*,
\"
name
\"
:
\"
$h
\"
"
|
cut
-d
:
-f
2 |
cut
-d
,
-f
1
)
_domain_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:[^,]*,
\"
name
\"
:
\"
$h
\"
"
|
cut
-d
:
-f
2 |
cut
-d
,
-f
1
)
_debug _domain_id
"
$_domain_id
"
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
"
...
...
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