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
69f718d4
Commit
69f718d4
authored
Nov 17, 2020
by
jakelamotta
Committed by
neil
Dec 23, 2020
Browse files
Adds dnsapi support for Simply.com
parent
0982b98f
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_simply.sh
View file @
69f718d4
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
#
#
#SIMPLY_Api="https://api.simply.com/1/[ACCOUNTNAME]/[APIKEY]"
#SIMPLY_Api="https://api.simply.com/1/[ACCOUNTNAME]/[APIKEY]"
SIMPLY_Api_Default
=
"https://api.simply.com/1"
SIMPLY_Api
=
"https://api.simply.com/1"
######## Public functions #####################
######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_simply_add
()
{
dns_simply_add
()
{
fulldomain
=
$1
fulldomain
=
$1
...
@@ -36,6 +36,7 @@ dns_simply_add() {
...
@@ -36,6 +36,7 @@ dns_simply_add() {
_err
"Could not add DNS record"
_err
"Could not add DNS record"
return
1
return
1
fi
fi
return
0
return
0
}
}
...
@@ -58,37 +59,30 @@ dns_simply_rm() {
...
@@ -58,37 +59,30 @@ dns_simply_rm() {
_debug _sub_domain
"
$_sub_domain
"
_debug _sub_domain
"
$_sub_domain
"
_debug _domain
"
$_domain
"
_debug _domain
"
$_domain
"
_debug
txtvalue
"
$txtvalue
"
_debug
"
$txtvalue
"
_
info
"Getting
all
existing records"
_
debug
"Getting existing records"
if
!
_simply_get_all_records
"
$_domain
"
;
then
if
!
_simply_get_all_records
"
$_domain
"
;
then
_err
"invalid domain"
_err
"invalid domain"
return
1
return
1
fi
fi
records
=
$(
echo
"
$response
"
|
tr
'{'
"
\n
"
|
grep
'record_id\|type\|data\|\name'
|
sed
's/\"record_id/;\"record_id/'
|
tr
"
\n
"
' '
|
tr
-d
' '
|
tr
';'
' '
)
records
=
$(
echo
"
$response
"
|
tr
'{'
"
\n
"
|
grep
'record_id\|type\|data\|\name'
|
sed
's/\"record_id/;\"record_id/'
)
record_array
=(
`
echo
$records
|tr
-d
' '
|
tr
';'
' '
`
)
nr_of_deleted_records
=
0
nr_of_deleted_records
=
0
_info
"Fetching txt record"
for
record
in
$records
;
do
_debug record
"
$record
"
record_data
=
$(
echo
"
$record
"
|
cut
-d
","
-f
3 |
sed
's/"//g'
|
grep
"data"
|
cut
-d
":"
-f
2
)
for
((
i
=
0
;
i<
=
${#
record_array
[@]
}
;
i++
))
;
do
record_type
=
$(
echo
"
$record
"
|
cut
-d
","
-f
4 |
sed
's/"//g'
|
grep
"type"
|
cut
-d
":"
-f
2
)
_debug2 record_data
"
$record_data
"
record
=
"
${
record_array
[
$i
]
}
"
_debug2 record_type
"
$record_type
"
if
[
"
$record
_data
"
=
"
$txtvalue
"
]
&&
[
"
$record
_type
"
=
"TXT"
]
;
then
if
[
[
"
$record
"
==
*
"
$txtvalue
"
*
&&
"
$record
"
=
=
*
"TXT"
*
]
]
;
then
record_id
=
$(
echo
"
$record
"
|
cut
-d
","
-f
1 |
grep
"record_id"
|
cut
-d
":"
-f
2
)
_info
"Deleting record:
$record
"
_info
"Deleting record
$record
"
record_id
=
`
echo
$record
|
cut
-d
","
-f
1 |
grep
"record_id"
|
cut
-d
":"
-f
2
`
_debug2 record_id
"
$record_id
"
if
[
"
$record_id
"
-gt
0
]
;
then
if
[
[
$record_id
-gt
0
]
]
;
then
if
!
_simply_delete_record
"
$_domain
"
"
$_sub_domain
"
"
$record_id
"
;
then
if
!
_simply_delete_record
"
$_domain
"
"
$_sub_domain
"
"
$record_id
"
;
then
_err
"Record with id
$record_id
could not be deleted"
_err
"Record with id
$record_id
could not be deleted"
...
@@ -105,7 +99,7 @@ dns_simply_rm() {
...
@@ -105,7 +99,7 @@ dns_simply_rm() {
done
done
if
[
"
$nr_of_deleted_records
"
-eq
0
]
;
then
if
[
[
$nr_of_deleted_records
-eq
0
]
]
;
then
_err
"No record deleted, the DNS record needs to be removed manually."
_err
"No record deleted, the DNS record needs to be removed manually."
else
else
_info
"Deleted
$nr_of_deleted_records
record"
_info
"Deleted
$nr_of_deleted_records
record"
...
@@ -204,7 +198,7 @@ _simply_delete_record() {
...
@@ -204,7 +198,7 @@ _simply_delete_record() {
sub_domain
=
$2
sub_domain
=
$2
record_id
=
$3
record_id
=
$3
_debug
record_id
"Delete record with id
$record_id
"
_debug
"Delete record with id
$record_id
"
if
!
_simply_rest DELETE
"my/products/
$domain
/dns/records/
$record_id
"
;
then
if
!
_simply_rest DELETE
"my/products/
$domain
/dns/records/
$record_id
"
;
then
_err
"Deleting record not successfull!"
_err
"Deleting record not successfull!"
...
@@ -219,9 +213,9 @@ _simply_rest() {
...
@@ -219,9 +213,9 @@ _simply_rest() {
ep
=
"
$2
"
ep
=
"
$2
"
data
=
"
$3
"
data
=
"
$3
"
_debug
2 d
ata
"
$data
"
_debug
"D
ata
:
$data
"
_debug
2 ep
"
$ep
"
_debug
"Methodcall:
$ep
"
_debug
2 m
"
$m
"
_debug
"Call type:
$m
"
export
_H1
=
"Content-Type: application/json"
export
_H1
=
"Content-Type: application/json"
...
@@ -242,6 +236,5 @@ _simply_rest() {
...
@@ -242,6 +236,5 @@ _simply_rest() {
_err
"It seems that your api key or accountnumber is not correct."
_err
"It seems that your api key or accountnumber is not correct."
return
1
return
1
fi
fi
return
0
return
0
}
}
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