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
22f7ac22
Commit
22f7ac22
authored
Dec 24, 2020
by
Lukas Brocke
Browse files
dnsapi/ionos: Run shfmt
parent
a00046f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_ionos.sh
View file @
22f7ac22
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
IONOS_API
=
"https://api.hosting.ionos.com/dns"
IONOS_API
=
"https://api.hosting.ionos.com/dns"
IONOS_ROUTE_ZONES
=
"/v1/zones"
IONOS_ROUTE_ZONES
=
"/v1/zones"
IONOS_TXT_TTL
=
60
# min
u
mum accepted by API
IONOS_TXT_TTL
=
60
# min
i
mum accepted by API
IONOS_TXT_PRIO
=
10
IONOS_TXT_PRIO
=
10
dns_ionos_add
()
{
dns_ionos_add
()
{
...
@@ -25,7 +25,7 @@ dns_ionos_add() {
...
@@ -25,7 +25,7 @@ dns_ionos_add() {
_body
=
"{
\"
name
\"
:
\"
$_sub_domain
.
$_domain
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:
$IONOS_TXT_TTL
,
\"
prio
\"
:
$IONOS_TXT_PRIO
,
\"
disabled
\"
:false}"
_body
=
"{
\"
name
\"
:
\"
$_sub_domain
.
$_domain
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:
$IONOS_TXT_TTL
,
\"
prio
\"
:
$IONOS_TXT_PRIO
,
\"
disabled
\"
:false}"
if
_ionos_rest PATCH
"
$IONOS_ROUTE_ZONES
/
$_zone_id
"
"
$_body
"
&&
[
-z
"
$response
"
]
;
then
if
_ionos_rest PATCH
"
$IONOS_ROUTE_ZONES
/
$_zone_id
"
"
$_body
"
&&
[
-z
"
$response
"
]
;
then
_info
"TXT record
for _sub_domain.
$_domain
has been created successfully."
_info
"TXT record has been created successfully."
return
0
return
0
fi
fi
...
@@ -44,7 +44,7 @@ dns_ionos_rm() {
...
@@ -44,7 +44,7 @@ dns_ionos_rm() {
fi
fi
if
_ionos_rest DELETE
"
$IONOS_ROUTE_ZONES
/
$_zone_id
/records/
$_record_id
"
&&
[
-z
"
$response
"
]
;
then
if
_ionos_rest DELETE
"
$IONOS_ROUTE_ZONES
/
$_zone_id
/records/
$_record_id
"
&&
[
-z
"
$response
"
]
;
then
_info
"TXT record
for _sub_domain.
$_domain
has been deleted successfully."
_info
"TXT record has been deleted successfully."
return
0
return
0
fi
fi
...
@@ -54,7 +54,7 @@ dns_ionos_rm() {
...
@@ -54,7 +54,7 @@ dns_ionos_rm() {
_ionos_init
()
{
_ionos_init
()
{
IONOS_PREFIX
=
"
${
IONOS_PREFIX
:-
$(
_readaccountconf_mutable IONOS_PREFIX
)
}
"
IONOS_PREFIX
=
"
${
IONOS_PREFIX
:-
$(
_readaccountconf_mutable IONOS_PREFIX
)
}
"
IONOS_SECRET
=
"
${
IONOS_SECRET
:-
$(
_readaccountconf_mutable IONOS_SECRET
)
}
"
IONOS_SECRET
=
"
${
IONOS_SECRET
:-
$(
_readaccountconf_mutable IONOS_SECRET
)
}
"
if
[
-z
"
$IONOS_PREFIX
"
]
||
[
-z
"
$IONOS_SECRET
"
]
;
then
if
[
-z
"
$IONOS_PREFIX
"
]
||
[
-z
"
$IONOS_SECRET
"
]
;
then
_err
"You didn't specify an IONOS api prefix and secret yet."
_err
"You didn't specify an IONOS api prefix and secret yet."
_err
"Read https://beta.developer.hosting.ionos.de/docs/getstarted to learn how to get a prefix and secret."
_err
"Read https://beta.developer.hosting.ionos.de/docs/getstarted to learn how to get a prefix and secret."
...
@@ -91,7 +91,7 @@ _get_root() {
...
@@ -91,7 +91,7 @@ _get_root() {
_zone
=
"
$(
echo
"
$response
"
| _egrep_o
"{.*
\"
name
\"
:
\s
*
\"
$h
\"
.*}"
)
"
_zone
=
"
$(
echo
"
$response
"
| _egrep_o
"{.*
\"
name
\"
:
\s
*
\"
$h
\"
.*}"
)
"
if
[
"
$_zone
"
]
;
then
if
[
"
$_zone
"
]
;
then
_zone_id
=
$(
printf
"%s
\n
"
"
$_zone
"
| _egrep_o
"
\"
id
\"
:
\s
*
\"
[a-fA-F0-9-]+
\"
"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
'\"'
)
_zone_id
=
$(
printf
"%s
\n
"
"
$_zone
"
| _egrep_o
"
\"
id
\"
:
\s
*
\"
[a-fA-F0-9-]+
\"
"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
'\"'
)
if
[
"
$_zone_id
"
]
;
then
if
[
"
$_zone_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
...
@@ -115,13 +115,13 @@ _ionos_get_record() {
...
@@ -115,13 +115,13 @@ _ionos_get_record() {
zone_id
=
$2
zone_id
=
$2
if
_ionos_rest GET
"
$IONOS_ROUTE_ZONES
/
$zone_id
?recordName=
$fulldomain
&recordType=TXT"
;
then
if
_ionos_rest GET
"
$IONOS_ROUTE_ZONES
/
$zone_id
?recordName=
$fulldomain
&recordType=TXT"
;
then
response
=
"
$(
echo
"
$response
"
|
tr
-d
"
\n
"
)
"
response
=
"
$(
echo
"
$response
"
|
tr
-d
"
\n
"
)
"
_record
=
"
$(
echo
"
$response
"
| _egrep_o
"{
\"
name
\"
:
\s
*
\"
$fulldomain
\"
.*}"
)
"
_record
=
"
$(
echo
"
$response
"
| _egrep_o
"{
\"
name
\"
:
\s
*
\"
$fulldomain
\"
.*}"
)
"
if
[
"
$_record
"
]
;
then
if
[
"
$_record
"
]
;
then
_record_id
=
$(
printf
"%s
\n
"
"
$_record
"
| _egrep_o
"
\"
id
\"
:
\s
*
\"
[a-fA-F0-9-]+
\"
"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
'\"'
)
_record_id
=
$(
printf
"%s
\n
"
"
$_record
"
| _egrep_o
"
\"
id
\"
:
\s
*
\"
[a-fA-F0-9-]+
\"
"
| _head_n 1 |
cut
-d
:
-f
2 |
tr
-d
'\"'
)
return
0
return
0
fi
fi
fi
fi
...
...
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