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
9c4f7aa6
Commit
9c4f7aa6
authored
Dec 11, 2017
by
MaomiHz
Browse files
check for env var exist in DigitalOcean API
parent
e75b5607
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_dgon.sh
View file @
9c4f7aa6
...
@@ -20,12 +20,22 @@
...
@@ -20,12 +20,22 @@
dns_dgon_add
()
{
dns_dgon_add
()
{
fulldomain
=
"
$(
echo
"
$1
"
| _lower_case
)
"
fulldomain
=
"
$(
echo
"
$1
"
| _lower_case
)
"
txtvalue
=
$2
txtvalue
=
$2
DO_API_KEY
=
"
${
DO_API_KEY
:-
$(
_readaccountconf_mutable DO_API_KEY
)
}
"
# Check if API Key Exist
if
[
-z
"
$DO_API_KEY
"
]
;
then
DO_API_KEY
=
""
_err
"You did not specify DigitalOcean API key."
_err
"Please export DO_API_KEY and try again."
return
1
fi
_info
"Using digitalocean dns validation - add record"
_info
"Using digitalocean dns validation - add record"
_debug fulldomain
"
$fulldomain
"
_debug fulldomain
"
$fulldomain
"
_debug txtvalue
"
$txtvalue
"
_debug txtvalue
"
$txtvalue
"
## save the env vars (key and domain split location) for later automated use
## save the env vars (key and domain split location) for later automated use
_saveaccountconf DO_API_KEY
"
$DO_API_KEY
"
_saveaccountconf
_mutable
DO_API_KEY
"
$DO_API_KEY
"
## split the domain for DO API
## split the domain for DO API
if
!
_get_base_domain
"
$fulldomain
"
;
then
if
!
_get_base_domain
"
$fulldomain
"
;
then
...
@@ -39,7 +49,7 @@ dns_dgon_add() {
...
@@ -39,7 +49,7 @@ dns_dgon_add() {
export
_H1
=
"Content-Type: application/json"
export
_H1
=
"Content-Type: application/json"
export
_H2
=
"Authorization: Bearer
$DO_API_KEY
"
export
_H2
=
"Authorization: Bearer
$DO_API_KEY
"
PURL
=
'https://api.digitalocean.com/v2/domains/'
$_domain
'/records'
PURL
=
'https://api.digitalocean.com/v2/domains/'
$_domain
'/records'
PBODY
=
'{"type":"TXT","name":"'
$_sub_domain
'","data":"'
$txtvalue
'"}'
PBODY
=
'{"type":"TXT","name":"'
$_sub_domain
'","data":"'
$txtvalue
'"
,"ttl":120
}'
_debug PURL
"
$PURL
"
_debug PURL
"
$PURL
"
_debug PBODY
"
$PBODY
"
_debug PBODY
"
$PBODY
"
...
@@ -65,6 +75,16 @@ dns_dgon_add() {
...
@@ -65,6 +75,16 @@ dns_dgon_add() {
dns_dgon_rm
()
{
dns_dgon_rm
()
{
fulldomain
=
"
$(
echo
"
$1
"
| _lower_case
)
"
fulldomain
=
"
$(
echo
"
$1
"
| _lower_case
)
"
txtvalue
=
$2
txtvalue
=
$2
DO_API_KEY
=
"
${
DO_API_KEY
:-
$(
_readaccountconf_mutable DO_API_KEY
)
}
"
# Check if API Key Exist
if
[
-z
"
$DO_API_KEY
"
]
;
then
DO_API_KEY
=
""
_err
"You did not specify DigitalOcean API key."
_err
"Please export DO_API_KEY and try again."
return
1
fi
_info
"Using digitalocean dns validation - remove record"
_info
"Using digitalocean dns validation - remove record"
_debug fulldomain
"
$fulldomain
"
_debug fulldomain
"
$fulldomain
"
_debug txtvalue
"
$txtvalue
"
_debug txtvalue
"
$txtvalue
"
...
...
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