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
fcb97f80
Commit
fcb97f80
authored
Nov 18, 2020
by
jakelamotta
Browse files
Removes tabs and trailing spaces
parent
9ad05e64
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_simply.sh
View file @
fcb97f80
...
@@ -21,28 +21,29 @@ dns_simply_add() {
...
@@ -21,28 +21,29 @@ dns_simply_add() {
_simply_save_config
_simply_save_config
_debug
"First detect the root zone"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
_err
"invalid domain"
return
1
return
1
fi
fi
_debug _sub_domain
"
$_sub_domain
"
_debug _sub_domain
"
$_sub_domain
"
_debug _domain
"
$_domain
"
_debug _domain
"
$_domain
"
_info
"Adding record"
_info
"Adding record"
if
!
_simply_add_record
"
$_domain
"
"
$_sub_domain
"
"
$txtvalue
"
;
then
if
!
_simply_add_record
"
$_domain
"
"
$_sub_domain
"
"
$txtvalue
"
;
then
_err
"Could not add DNS record"
_err
"Could not add DNS record"
return
1
return
1
fi
fi
return
0
return
0
}
}
dns_simply_rm
()
{
dns_simply_rm
()
{
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
if
!
_simply_load_config
;
then
if
!
_simply_load_config
;
then
return
1
return
1
fi
fi
...
@@ -61,12 +62,12 @@ dns_simply_rm() {
...
@@ -61,12 +62,12 @@ dns_simply_rm() {
_debug txtvalue
"
$txtvalue
"
_debug txtvalue
"
$txtvalue
"
_info
"Getting all existing records"
_info
"Getting all 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/'
|
tr
"
\n
"
' '
|
tr
-d
' '
|
tr
';'
' '
)
nr_of_deleted_records
=
0
nr_of_deleted_records
=
0
...
@@ -74,27 +75,27 @@ dns_simply_rm() {
...
@@ -74,27 +75,27 @@ dns_simply_rm() {
for
record
in
$records
;
do
for
record
in
$records
;
do
_debug record
"
$record
"
_debug record
"
$record
"
record_data
=
$(
echo
"
$record
"
|
cut
-d
","
-f
3 |
sed
's/"//g'
|
grep
"data"
|
cut
-d
":"
-f
2
)
record_type
=
$(
echo
"
$record
"
|
cut
-d
","
-f
4 |
sed
's/"//g'
|
grep
"type"
|
cut
-d
":"
-f
2
)
_debug2 record_data
"
$record_data
"
_debug2 record_type
"
$record_type
"
if
[
"
$record_data
"
=
"
$txtvalue
"
]
&&
[
"
$record_type
"
=
"TXT"
]
;
then
record_data
=
$(
echo
"
$record
"
|
cut
-d
","
-f
3 |
sed
's/"//g'
|
grep
"data"
|
cut
-d
":"
-f
2
)
record_type
=
$(
echo
"
$record
"
|
cut
-d
","
-f
4 |
sed
's/"//g'
|
grep
"type"
|
cut
-d
":"
-f
2
)
_debug2 record_data
"
$record_data
"
_debug2 record_type
"
$record_type
"
if
[
"
$record_data
"
=
"
$txtvalue
"
]
&&
[
"
$record_type
"
=
"TXT"
]
;
then
record_id
=
$(
echo
"
$record
"
|
cut
-d
","
-f
1 |
grep
"record_id"
|
cut
-d
":"
-f
2
)
record_id
=
$(
echo
"
$record
"
|
cut
-d
","
-f
1 |
grep
"record_id"
|
cut
-d
":"
-f
2
)
_info
"Deleting record
$record
"
_info
"Deleting record
$record
"
_debug2 record_id
"
$record_id
"
_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"
return
1
return
1
fi
fi
nr_of_deleted_records
=
1
nr_of_deleted_records
=
1
break
break
else
else
...
@@ -102,7 +103,7 @@ dns_simply_rm() {
...
@@ -102,7 +103,7 @@ dns_simply_rm() {
break
break
fi
fi
fi
fi
done
done
if
[
"
$nr_of_deleted_records
"
-eq
0
]
;
then
if
[
"
$nr_of_deleted_records
"
-eq
0
]
;
then
...
@@ -110,7 +111,7 @@ dns_simply_rm() {
...
@@ -110,7 +111,7 @@ dns_simply_rm() {
else
else
_info
"Deleted
$nr_of_deleted_records
record"
_info
"Deleted
$nr_of_deleted_records
record"
fi
fi
return
0
return
0
}
}
...
@@ -242,6 +243,6 @@ _simply_rest() {
...
@@ -242,6 +243,6 @@ _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