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
1d1f6161
Commit
1d1f6161
authored
Oct 25, 2019
by
Rolph Haspers
Browse files
Check for root domain via API
parent
f0d6d467
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_leaseweb.sh
View file @
1d1f6161
...
@@ -88,14 +88,24 @@ _get_root() {
...
@@ -88,14 +88,24 @@ _get_root() {
i
=
$(
_math
"
$i
"
- 1
)
i
=
$(
_math
"
$i
"
- 1
)
while
true
;
do
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
"
$i
"
-100
)
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
if
[
-z
"
$h
"
]
;
then
if
[
-z
"
$h
"
]
;
then
return
1
return
1
#not valid domain
fi
#Check API if domain exists
if
_lsw_api
"GET"
"
$h
"
;
then
if
[
"
$_code
"
=
"200"
]
;
then
_domain
=
"
$h
"
return
0
fi
fi
i
=
$(
_math
"
$i
"
- 1
)
if
((
$i
< 1
))
;
then
return
1
#not found
fi
fi
_domain
=
"
$h
"
return
0
done
done
_debug
"
$domain
not found"
return
1
return
1
}
}
...
@@ -109,6 +119,14 @@ _lsw_api() {
...
@@ -109,6 +119,14 @@ _lsw_api() {
export
_H2
=
"Content-Type: application/json"
export
_H2
=
"Content-Type: application/json"
export
_H1
=
"X-Lsw-Auth:
${
LSW_Key
}
"
export
_H1
=
"X-Lsw-Auth:
${
LSW_Key
}
"
if
[
"
$cmd
"
=
"GET"
]
;
then
response
=
"
$(
_get
"
$LSW_API
/
$domain
"
)
"
_code
=
"
$(
grep
"^HTTP"
"
$HTTP_HEADER
"
| _tail_n 1 |
cut
-d
" "
-f
2 |
tr
-d
"
\\
r
\\
n"
)
"
_debug
"http response code
$_code
"
_debug response
"
$response
"
return
0
fi
if
[
"
$cmd
"
=
"POST"
]
;
then
if
[
"
$cmd
"
=
"POST"
]
;
then
data
=
"{
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
: [
\"
$txtvalue
\"
],
\"
ttl
\"
: 60}"
data
=
"{
\"
name
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
: [
\"
$txtvalue
\"
],
\"
ttl
\"
: 60}"
response
=
"
$(
_post
"
$data
"
"
$LSW_API
/
$domain
/resourceRecordSets"
"
$data
"
"POST"
)
"
response
=
"
$(
_post
"
$data
"
"
$LSW_API
/
$domain
/resourceRecordSets"
"
$data
"
"POST"
)
"
...
...
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