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
aaae83ef
Commit
aaae83ef
authored
Feb 12, 2022
by
peter
Browse files
check for return values
parent
0c9a6da6
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_curanet.sh
View file @
aaae83ef
...
@@ -33,9 +33,15 @@ dns_curanet_add() {
...
@@ -33,9 +33,15 @@ dns_curanet_add() {
_saveaccountconf_mutable CURANET_AUTHCLIENTID
"
$CURANET_AUTHCLIENTID
"
_saveaccountconf_mutable CURANET_AUTHCLIENTID
"
$CURANET_AUTHCLIENTID
"
_saveaccountconf_mutable CURANET_AUTHSECRET
"
$CURANET_AUTHSECRET
"
_saveaccountconf_mutable CURANET_AUTHSECRET
"
$CURANET_AUTHSECRET
"
gettoken
if
!
_get_token
;
then
_err
"Unable to get token"
return
1
fi
_get_root
"
$fulldomain
"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"Invalid domain"
return
1
fi
export
_H1
=
"Content-Type: application/json-patch+json"
export
_H1
=
"Content-Type: application/json-patch+json"
export
_H2
=
"Accept: application/json"
export
_H2
=
"Accept: application/json"
...
@@ -65,9 +71,15 @@ dns_curanet_rm() {
...
@@ -65,9 +71,15 @@ dns_curanet_rm() {
CURANET_AUTHCLIENTID
=
"
${
CURANET_AUTHCLIENTID
:-
$(
_readaccountconf_mutable CURANET_AUTHCLIENTID
)
}
"
CURANET_AUTHCLIENTID
=
"
${
CURANET_AUTHCLIENTID
:-
$(
_readaccountconf_mutable CURANET_AUTHCLIENTID
)
}
"
CURANET_AUTHSECRET
=
"
${
CURANET_AUTHSECRET
:-
$(
_readaccountconf_mutable CURANET_AUTHSECRET
)
}
"
CURANET_AUTHSECRET
=
"
${
CURANET_AUTHSECRET
:-
$(
_readaccountconf_mutable CURANET_AUTHSECRET
)
}
"
gettoken
if
!
_get_token
;
then
_err
"Unable to get token"
return
1
fi
_get_root
"
$fulldomain
"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"Invalid domain"
return
1
fi
_debug
"Getting current record list to identify TXT to delete"
_debug
"Getting current record list to identify TXT to delete"
...
@@ -90,13 +102,19 @@ dns_curanet_rm() {
...
@@ -90,13 +102,19 @@ dns_curanet_rm() {
#################### Private functions below ##################################
#################### Private functions below ##################################
gettoken
()
{
_
get
_
token
()
{
response
=
"
$(
_post
"grant_type=client_credentials&client_id=
$CURANET_AUTHCLIENTID
&client_secret=
$CURANET_AUTHSECRET
&scope=dns"
"
$CURANET_AUTH_URL
"
""
""
)
"
response
=
"
$(
_post
"grant_type=client_credentials&client_id=
$CURANET_AUTHCLIENTID
&client_secret=
$CURANET_AUTHSECRET
&scope=dns"
"
$CURANET_AUTH_URL
"
""
""
)
"
if
!
_contains
"
$response
"
"access_token"
;
then
if
!
_contains
"
$response
"
"access_token"
;
then
_err
"Unable get access token"
_err
"Unable get access token"
return
1
return
1
fi
fi
CURANET_ACCESS_TOKEN
=
$(
echo
"
$response
"
| _egrep_o
"
\"
access_token
\"
:
\"
[^
\"
]+"
|
cut
-c
17-
)
CURANET_ACCESS_TOKEN
=
$(
echo
"
$response
"
| _egrep_o
"
\"
access_token
\"
:
\"
[^
\"
]+"
|
cut
-c
17-
)
if
[
-z
"
$CURANET_ACCESS_TOKEN
"
]
;
then
_err
"Unable to get token"
return
1
fi
}
}
#_acme-challenge.www.domain.com
#_acme-challenge.www.domain.com
...
...
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