Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
2cc50a2b
Commit
2cc50a2b
authored
Feb 08, 2020
by
Wout
Browse files
Cosmetic fixes.
parent
e8e6feeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_constellix.sh
View file @
2cc50a2b
...
@@ -2,26 +2,28 @@
...
@@ -2,26 +2,28 @@
# Author: Wout Decre <wout@canodus.be>
# Author: Wout Decre <wout@canodus.be>
CONSTELLIX_A
PI
=
"https://api.dns.constellix.com/v1"
CONSTELLIX_A
pi
=
"https://api.dns.constellix.com/v1"
#CONSTELLIX_K
EY
="XXX"
#CONSTELLIX_K
ey
="XXX"
#CONSTELLIX_S
ECRET
="XXX"
#CONSTELLIX_S
ecret
="XXX"
######## Public functions #####################
######## Public functions #####################
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
# Used to add txt record
dns_constellix_add
()
{
dns_constellix_add
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
CONSTELLIX_K
EY
=
"
${
CONSTELLIX_K
EY
:-
$(
_readaccountconf_mutable CONSTELLIX_K
EY
)
}
"
CONSTELLIX_K
ey
=
"
${
CONSTELLIX_K
ey
:-
$(
_readaccountconf_mutable CONSTELLIX_K
ey
)
}
"
CONSTELLIX_S
ECRET
=
"
${
CONSTELLIX_S
ECRET
:-
$(
_readaccountconf_mutable CONSTELLIX_S
ECRET
)
}
"
CONSTELLIX_S
ecret
=
"
${
CONSTELLIX_S
ecret
:-
$(
_readaccountconf_mutable CONSTELLIX_S
ecret
)
}
"
if
[
-z
"
$CONSTELLIX_K
EY
"
]
||
[
-z
"
$CONSTELLIX_S
ECRET
"
]
;
then
if
[
-z
"
$CONSTELLIX_K
ey
"
]
||
[
-z
"
$CONSTELLIX_S
ecret
"
]
;
then
_err
"You did not specify the Contellix API key and secret yet."
_err
"You did not specify the Contellix API key and secret yet."
return
1
return
1
fi
fi
_saveaccountconf_mutable CONSTELLIX_K
EY
"
$CONSTELLIX_K
EY
"
_saveaccountconf_mutable CONSTELLIX_K
ey
"
$CONSTELLIX_K
ey
"
_saveaccountconf_mutable CONSTELLIX_S
ECRET
"
$CONSTELLIX_S
ECRET
"
_saveaccountconf_mutable CONSTELLIX_S
ecret
"
$CONSTELLIX_S
ecret
"
if
!
_get_root
"
$fulldomain
"
;
then
if
!
_get_root
"
$fulldomain
"
;
then
_err
"Invalid domain"
_err
"Invalid domain"
...
@@ -40,14 +42,16 @@ dns_constellix_add() {
...
@@ -40,14 +42,16 @@ dns_constellix_add() {
fi
fi
}
}
# Usage: fulldomain txtvalue
# Used to remove the txt record after validation
dns_constellix_rm
()
{
dns_constellix_rm
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
CONSTELLIX_K
EY
=
"
${
CONSTELLIX_K
EY
:-
$(
_readaccountconf_mutable CONSTELLIX_K
EY
)
}
"
CONSTELLIX_K
ey
=
"
${
CONSTELLIX_K
ey
:-
$(
_readaccountconf_mutable CONSTELLIX_K
ey
)
}
"
CONSTELLIX_S
ECRET
=
"
${
CONSTELLIX_S
ECRET
:-
$(
_readaccountconf_mutable CONSTELLIX_S
ECRET
)
}
"
CONSTELLIX_S
ecret
=
"
${
CONSTELLIX_S
ecret
:-
$(
_readaccountconf_mutable CONSTELLIX_S
ecret
)
}
"
if
[
-z
"
$CONSTELLIX_K
EY
"
]
||
[
-z
"
$CONSTELLIX_S
ECRET
"
]
;
then
if
[
-z
"
$CONSTELLIX_K
ey
"
]
||
[
-z
"
$CONSTELLIX_S
ecret
"
]
;
then
_err
"You did not specify the Contellix API key and secret yet."
_err
"You did not specify the Contellix API key and secret yet."
return
1
return
1
fi
fi
...
@@ -112,9 +116,9 @@ _constellix_rest() {
...
@@ -112,9 +116,9 @@ _constellix_rest() {
_debug
"
$ep
"
_debug
"
$ep
"
rdate
=
$(
date
+
"%s"
)
"000"
rdate
=
$(
date
+
"%s"
)
"000"
hmac
=
$(
printf
"%s"
"
$rdate
"
| _hmac sha1
"
$(
printf
"%s"
"
$CONSTELLIX_S
ECRET
"
| _hex_dump |
tr
-d
' '
)
"
| _base64
)
hmac
=
$(
printf
"%s"
"
$rdate
"
| _hmac sha1
"
$(
printf
"%s"
"
$CONSTELLIX_S
ecret
"
| _hex_dump |
tr
-d
' '
)
"
| _base64
)
export
_H1
=
"x-cnsdns-apiKey:
$CONSTELLIX_K
EY
"
export
_H1
=
"x-cnsdns-apiKey:
$CONSTELLIX_K
ey
"
export
_H2
=
"x-cnsdns-requestDate:
$rdate
"
export
_H2
=
"x-cnsdns-requestDate:
$rdate
"
export
_H3
=
"x-cnsdns-hmac:
$hmac
"
export
_H3
=
"x-cnsdns-hmac:
$hmac
"
export
_H4
=
"Accept: application/json"
export
_H4
=
"Accept: application/json"
...
@@ -122,9 +126,9 @@ _constellix_rest() {
...
@@ -122,9 +126,9 @@ _constellix_rest() {
if
[
"
$m
"
!=
"GET"
]
;
then
if
[
"
$m
"
!=
"GET"
]
;
then
_debug data
"
$data
"
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$CONSTELLIX_A
PI
/
$ep
"
""
"
$m
"
)
"
response
=
"
$(
_post
"
$data
"
"
$CONSTELLIX_A
pi
/
$ep
"
""
"
$m
"
)
"
else
else
response
=
"
$(
_get
"
$CONSTELLIX_A
PI
/
$ep
"
)
"
response
=
"
$(
_get
"
$CONSTELLIX_A
pi
/
$ep
"
)
"
fi
fi
if
[
"
$?
"
!=
"0"
]
;
then
if
[
"
$?
"
!=
"0"
]
;
then
...
...
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