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
df199c57
Commit
df199c57
authored
Jul 11, 2022
by
Bjarke Bruun
Browse files
Updated API call for OpenBSD sed and tr as newlines does not work there
parent
c1ba4f1b
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_dnsservices.sh
View file @
df199c57
...
@@ -156,12 +156,13 @@ _get_root() {
...
@@ -156,12 +156,13 @@ _get_root() {
fi
fi
# Setup variables used by other functions to communicate with DNS.Services API
# Setup variables used by other functions to communicate with DNS.Services API
zoneInfo
=
$(
echo
"
$result
"
|
sed
"s,
\"
zones,
\n
&,g"
|
grep
zones |
cut
-d
'['
-f2
|
cut
-d
']'
-f1
|
tr
'}'
'\n'
|
grep
"
\"
$rootZone
\"
"
)
#zoneInfo=$(echo "$result" | sed "s,\"zones,\n&,g" | grep zones | cut -d'[' -f2 | cut -d']' -f1 | tr '}' '\n' | grep "\"$rootZone\"")
zoneInfo
=
$(
echo
-e
"
$result
"
|
sed
-E
's,.*(zones)(.*),\1\2,g'
|
sed
-E
's,^(.*"name":")([^"]*)"(.*)$,\2,g'
)
rootZoneName
=
"
$rootZone
"
rootZoneName
=
"
$rootZone
"
subDomainName
=
"
$(
echo
"
$domain
"
|
sed
"s,
\.
$rootZone
,,g"
)
"
subDomainName
=
"
$(
echo
"
$domain
"
|
sed
"s,
\.
$rootZone
,,g"
)
"
subDomainNameClean
=
"
$(
echo
"
$domain
"
|
sed
"s,_acme-challenge.,,g"
)
"
subDomainNameClean
=
"
$(
echo
"
$domain
"
|
sed
"s,_acme-challenge.,,g"
)
"
rootZoneDomainID
=
$(
echo
"
$zoneInfo
"
|
tr
','
'\n'
|
grep
domain_id |
cut
-d
'"'
-f4
)
rootZoneDomainID
=
$(
echo
-e
"
$result
"
|
sed
-E
's,.*(zones)(.*),\1\2,g'
|
sed
-E
's,^(.*"domain_id":")([^"]*)"(.*)$,\2,g'
)
rootZoneServiceID
=
$(
echo
"
$zoneInfo
"
|
tr
','
'\n'
|
grep
service_id |
cut
-d
'"'
-f4
)
rootZoneServiceID
=
$(
echo
-e
"
$result
"
|
sed
-E
's,.*(zones)(.*),\1\2,g'
|
sed
-E
's,^(.*"service_id":")([^"]*)"(.*)$,\2,g'
)
_debug2 _get_root
"Root zone name :
$rootZoneName
"
_debug2 _get_root
"Root zone name :
$rootZoneName
"
_debug2 _get_root
"Root zone domain ID :
$rootZoneDomainID
"
_debug2 _get_root
"Root zone domain ID :
$rootZoneDomainID
"
...
@@ -190,7 +191,7 @@ createRecord() {
...
@@ -190,7 +191,7 @@ createRecord() {
result
=
$(
_post
"
$data
"
"
$DNSServices_API
/service/
$rootZoneServiceID
/dns/
$rootZoneDomainID
/records"
""
"POST"
)
result
=
$(
_post
"
$data
"
"
$DNSServices_API
/service/
$rootZoneServiceID
/dns/
$rootZoneDomainID
/records"
""
"POST"
)
_debug2 createRecord
"result from API:
$result
"
_debug2 createRecord
"result from API:
$result
"
if
[
"
$(
echo
"
$result
"
|
grep
'
"success":true
'
)
"
=
""
]
;
then
if
[
"
$(
echo
"
$result
"
|
_e
grep
_o
"
\
"
success
\
"
:true
"
)
"
=
""
]
;
then
_err
"Failed to create TXT record
$fulldomain
with content
$txtvalue
in zone
$rootZoneName
"
_err
"Failed to create TXT record
$fulldomain
with content
$txtvalue
in zone
$rootZoneName
"
_err
"
$result
"
_err
"
$result
"
return
1
return
1
...
@@ -211,7 +212,7 @@ deleteRecord() {
...
@@ -211,7 +212,7 @@ deleteRecord() {
fi
fi
result
=
"
$(
_H1
=
"
$_H1
"
_H2
=
"
$_H2
"
_get
"
$DNSServices_API
/service/
$rootZoneServiceID
/dns/
$rootZoneDomainID
"
)
"
result
=
"
$(
_H1
=
"
$_H1
"
_H2
=
"
$_H2
"
_get
"
$DNSServices_API
/service/
$rootZoneServiceID
/dns/
$rootZoneDomainID
"
)
"
recordInfo
=
"
$(
echo
"
$result
"
|
tr
'}'
'\n'
|
grep
"
\"
name
\"
:
\"
${
fulldomain
}
"
|
grep
"
\"
content
\"
:
\"
"
|
grep
"
${
txtvalue
}
"
)
"
recordInfo
=
"
$(
echo
"
$result
"
|
tr
'}'
'\n'
|
_e
grep
_o
"
\"
name
\"
:
\"
${
fulldomain
}
"
|
_e
grep
_o
"
\"
content
\"
:
\"
"
|
grep
"
${
txtvalue
}
"
)
"
_debug2 deleteRecord
"recordInfo=
$recordInfo
"
_debug2 deleteRecord
"recordInfo=
$recordInfo
"
recordID
=
"
$(
echo
"
$recordInfo
"
|
tr
','
'\n'
| _egrep_o
"
\"
id
\"
:
\"
[0-9]+
\"
"
|
cut
-d
'"'
-f4
)
"
recordID
=
"
$(
echo
"
$recordInfo
"
|
tr
','
'\n'
| _egrep_o
"
\"
id
\"
:
\"
[0-9]+
\"
"
|
cut
-d
'"'
-f4
)
"
...
...
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