Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
e10f447b
Commit
e10f447b
authored
Oct 25, 2019
by
Rolph Haspers
Browse files
Fixed some bugs, tested and working
parent
1d1f6161
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_leaseweb.sh
View file @
e10f447b
...
...
@@ -83,19 +83,20 @@ dns_leaseweb_rm() {
# returns
# _domain=domain.com
_get_root
()
{
domain
=
$1
i
=
"
$(
echo
"
$
full
domain
"
|
tr
'.'
' '
|
wc
-w
)
"
r
domain
=
$1
i
=
"
$(
echo
"
$
r
domain
"
|
tr
'.'
' '
|
wc
-w
)
"
i
=
$(
_math
"
$i
"
- 1
)
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
h
=
$(
printf
"%s"
"
$rdomain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
if
[
-z
"
$h
"
]
;
then
return
1
#not valid domain
fi
#Check API if domain exists
if
_lsw_api
"GET"
"
$h
"
;
then
if
[
"
$_code
"
=
"200"
]
;
then
if
[
"
$_code
"
=
"200"
]
;
then
_domain
=
"
$h
"
return
0
fi
...
...
@@ -111,16 +112,16 @@ _get_root() {
_lsw_api
()
{
cmd
=
$1
d
omain
=
$2
f
ulldomain
=
$3
tx
tvalue
=
$4
d
ata
=
$2
f
d
=
$3
tvalue
=
$4
# Construct the HTTP Authorization header
export
_H2
=
"Content-Type: application/json"
export
_H1
=
"X-Lsw-Auth:
${
LSW_Key
}
"
if
[
"
$cmd
"
=
"GET"
]
;
then
response
=
"
$(
_get
"
$LSW_API
/
$d
omain
"
)
"
response
=
"
$(
_get
"
$LSW_API
/
$d
"
)
"
_code
=
"
$(
grep
"^HTTP"
"
$HTTP_HEADER
"
| _tail_n 1 |
cut
-d
" "
-f
2 |
tr
-d
"
\\
r
\\
n"
)
"
_debug
"http response code
$_code
"
_debug response
"
$response
"
...
...
@@ -128,8 +129,8 @@ _lsw_api() {
fi
if
[
"
$cmd
"
=
"POST"
]
;
then
data
=
"{
\"
name
\"
:
\"
$f
ulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
: [
\"
$
tx
tvalue
\"
],
\"
ttl
\"
: 60}"
response
=
"
$(
_post
"
$data
"
"
$LSW_API
/
$d
omain
/resourceRecordSets"
"
$data
"
"POST"
)
"
data
=
"{
\"
name
\"
:
\"
$f
d
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
: [
\"
$tvalue
\"
],
\"
ttl
\"
: 60}"
response
=
"
$(
_post
"
$data
"
"
$LSW_API
/
$d
/resourceRecordSets"
"
$data
"
"POST"
)
"
_code
=
"
$(
grep
"^HTTP"
"
$HTTP_HEADER
"
| _tail_n 1 |
cut
-d
" "
-f
2 |
tr
-d
"
\\
r
\\
n"
)
"
_debug
"http response code
$_code
"
_debug response
"
$response
"
...
...
@@ -137,7 +138,7 @@ _lsw_api() {
fi
if
[
"
$cmd
"
=
"DELETE"
]
;
then
response
=
"
$(
_post
""
"
$LSW_API
/
$d
omain
/resourceRecordSets/
$f
ulldomain
/TXT"
""
"DELETE"
)
"
response
=
"
$(
_post
""
"
$LSW_API
/
$d
/resourceRecordSets/
$f
d
/TXT"
""
"DELETE"
)
"
_code
=
"
$(
grep
"^HTTP"
"
$HTTP_HEADER
"
| _tail_n 1 |
cut
-d
" "
-f
2 |
tr
-d
"
\\
r
\\
n"
)
"
_debug
"http response code
$_code
"
_debug response
"
$response
"
...
...
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