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
2b36f4f5
Commit
2b36f4f5
authored
Mar 16, 2019
by
neilpang
Browse files
update
parent
82b0ebb7
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_namecom.sh
View file @
2b36f4f5
...
@@ -13,6 +13,8 @@ dns_namecom_add() {
...
@@ -13,6 +13,8 @@ dns_namecom_add() {
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
Namecom_Username
=
"
${
Namecom_Username
:-
$(
_readaccountconf_mutable Namecom_Username
)
}
"
Namecom_Token
=
"
${
Namecom_Token
:-
$(
_readaccountconf_mutable Namecom_Token
)
}
"
# First we need name.com credentials.
# First we need name.com credentials.
if
[
-z
"
$Namecom_Username
"
]
;
then
if
[
-z
"
$Namecom_Username
"
]
;
then
Namecom_Username
=
""
Namecom_Username
=
""
...
@@ -29,8 +31,8 @@ dns_namecom_add() {
...
@@ -29,8 +31,8 @@ dns_namecom_add() {
fi
fi
# Save them in configuration.
# Save them in configuration.
_saveaccountconf Namecom_Username
"
$Namecom_Username
"
_saveaccountconf
_mutable
Namecom_Username
"
$Namecom_Username
"
_saveaccountconf Namecom_Token
"
$Namecom_Token
"
_saveaccountconf
_mutable
Namecom_Token
"
$Namecom_Token
"
# Login in using API
# Login in using API
if
!
_namecom_login
;
then
if
!
_namecom_login
;
then
...
@@ -46,7 +48,7 @@ dns_namecom_add() {
...
@@ -46,7 +48,7 @@ dns_namecom_add() {
# Add TXT record.
# Add TXT record.
_namecom_addtxt_json
=
"{
\"
host
\"
:
\"
$_sub_domain
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
answer
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:
\"
300
\"
}"
_namecom_addtxt_json
=
"{
\"
host
\"
:
\"
$_sub_domain
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
answer
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:
\"
300
\"
}"
if
_namecom_rest POST
"domains/
$_domain
/records"
"
$_namecom_addtxt_json
"
;
then
if
_namecom_rest POST
"domains/
$_domain
/records"
"
$_namecom_addtxt_json
"
;
then
_retvalue
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
$_sub_domain
\"
"
)
_retvalue
=
$(
echo
"
$response
"
| _egrep_o
"
\"
$_sub_domain
\"
"
)
if
[
"
$_retvalue
"
]
;
then
if
[
"
$_retvalue
"
]
;
then
_info
"Successfully added TXT record, ready for validation."
_info
"Successfully added TXT record, ready for validation."
return
0
return
0
...
@@ -63,6 +65,8 @@ dns_namecom_rm() {
...
@@ -63,6 +65,8 @@ dns_namecom_rm() {
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
Namecom_Username
=
"
${
Namecom_Username
:-
$(
_readaccountconf_mutable Namecom_Username
)
}
"
Namecom_Token
=
"
${
Namecom_Token
:-
$(
_readaccountconf_mutable Namecom_Token
)
}
"
if
!
_namecom_login
;
then
if
!
_namecom_login
;
then
return
1
return
1
fi
fi
...
@@ -75,7 +79,7 @@ dns_namecom_rm() {
...
@@ -75,7 +79,7 @@ dns_namecom_rm() {
# Get the record id.
# Get the record id.
if
_namecom_rest GET
"domains/
$_domain
/records"
;
then
if
_namecom_rest GET
"domains/
$_domain
/records"
;
then
_record_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:[0-9]+,
\"
domainName
\"
:
\"
$_domain
\"
,
\"
host
\"
:
\"
$_sub_domain
\"
,
\"
fqdn
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
answer
\"
:
\"
$txtvalue
\"
"
|
cut
-d
\"
-f
3 | _egrep_o
[
0-9]+
)
_record_id
=
$(
echo
"
$response
"
| _egrep_o
"
\"
id
\"
:[0-9]+,
\"
domainName
\"
:
\"
$_domain
\"
,
\"
host
\"
:
\"
$_sub_domain
\"
,
\"
fqdn
\"
:
\"
$fulldomain
.
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
answer
\"
:
\"
$txtvalue
\"
"
|
cut
-d
\"
-f
3 | _egrep_o
[
0-9]+
)
_debug record_id
"
$_record_id
"
_debug record_id
"
$_record_id
"
if
[
"
$_record_id
"
]
;
then
if
[
"
$_record_id
"
]
;
then
_info
"Successfully retrieved the record id for ACME challenge."
_info
"Successfully retrieved the record id for ACME challenge."
...
@@ -126,7 +130,7 @@ _namecom_login() {
...
@@ -126,7 +130,7 @@ _namecom_login() {
_namecom_auth
=
$(
printf
"%s:%s"
"
$Namecom_Username
"
"
$Namecom_Token
"
| _base64
)
_namecom_auth
=
$(
printf
"%s:%s"
"
$Namecom_Username
"
"
$Namecom_Token
"
| _base64
)
if
_namecom_rest GET
"hello"
;
then
if
_namecom_rest GET
"hello"
;
then
retcode
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
username
\"\:\"
$Namecom_Username
\"
"
)
retcode
=
$(
echo
"
$response
"
| _egrep_o
"
\"
username
\"\:\"
$Namecom_Username
\"
"
)
if
[
"
$retcode
"
]
;
then
if
[
"
$retcode
"
]
;
then
_info
"Successfully logged in."
_info
"Successfully logged in."
else
else
...
...
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