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
da7b1fb0
Unverified
Commit
da7b1fb0
authored
Apr 09, 2020
by
der-berni
Committed by
GitHub
Apr 09, 2020
Browse files
cleanup according to styleguide / ShellCheck
parent
5fac282e
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_one.sh
View file @
da7b1fb0
...
...
@@ -7,6 +7,9 @@
# Fixed by: @der-berni
# Modified: 2020-04-07
#
# Use ONECOM_KeepCnameProxy to keep the CNAME DNS record
# export ONECOM_KeepCnameProxy="1"
#
# export ONECOM_User="username"
# export ONECOM_Password="password"
#
...
...
@@ -56,14 +59,14 @@ dns_one_add() {
#Check if the TXT exists
_dns_one_getrecord
"TXT"
"
$subdomain
"
"
$txtvalue
"
if
[
!
-z
"
$id
"
]
;
then
if
[
-n
"
$id
"
]
;
then
_info
"
$(
__green
"Txt record with the same value found. Skip adding."
)
"
return
0
fi
_dns_one_addrecord
"TXT"
"
$subdomain
"
"
$txtvalue
"
if
[
-z
"
$id
"
]
;
then
_err
"Add
CNAME
record error."
_err
"Add
TXT
record error."
return
1
else
_info
"
$(
__green
"Added, OK (
$id
)"
)
"
...
...
@@ -103,7 +106,7 @@ dns_one_rm() {
else
#Check if the CNAME exists
_dns_one_getrecord
"CNAME"
"
$_sub_domain
"
"
$subdomain
.
$maindomain
"
if
[
!
-z
"
$id
"
]
;
then
if
[
-n
"
$id
"
]
;
then
_info
"
$(
__red
"Removing CNAME Proxy record: '
$(
__green
"
\"
$_sub_domain
\"
=>
\"
$subdomain
.
$maindomain
\"
"
)
'"
)
"
_dns_one_delrecord
"
$id
"
fi
...
...
@@ -118,7 +121,6 @@ dns_one_rm() {
fi
# delete entry
if
_dns_one_delrecord
"
$id
"
;
then
_info
"
$(
__green Removed, OK
)
"
return
0
...
...
@@ -162,6 +164,7 @@ _dns_one_login() {
# get credentials
ONECOM_KeepCnameProxy
=
"
${
ONECOM_KeepCnameProxy
:-
$(
_readaccountconf_mutable ONECOM_KeepCnameProxy
)
}
"
ONECOM_KeepCnameProxy
=
"
${
ONECOM_KeepCnameProxy
:-
0
}
"
ONECOM_User
=
"
${
ONECOM_User
:-
$(
_readaccountconf_mutable ONECOM_User
)
}
"
ONECOM_Password
=
"
${
ONECOM_Password
:-
$(
_readaccountconf_mutable ONECOM_Password
)
}
"
if
[
-z
"
$ONECOM_User
"
]
||
[
-z
"
$ONECOM_Password
"
]
;
then
...
...
@@ -173,6 +176,7 @@ _dns_one_login() {
fi
#save the api key and email to the account conf file.
_saveaccountconf_mutable ONECOM_KeepCnameProxy
"
$ONECOM_KeepCnameProxy
"
_saveaccountconf_mutable ONECOM_User
"
$ONECOM_User
"
_saveaccountconf_mutable ONECOM_Password
"
$ONECOM_Password
"
...
...
@@ -225,7 +229,6 @@ _dns_one_getrecord() {
id
=
$(
printf
--
"%s"
"
$response
"
|
sed
-n
"s/.*{
\"
type
\"
:
\"
dns_custom_records
\"
,
\"
id
\"
:
\"\(
[^
\"
]*
\)\"
,
\"
attributes
\"
:{
\"
prefix
\"
:
\"
${
name
}
\"
,
\"
type
\"
:
\"
${
type
}
\"
,
\"
content
\"
:
\"
${
value
}
\"
,
\"
priority
\"
:0,
\"
ttl
\"
:600}.*/
\1
/p"
)
fi
if
[
-z
"
$id
"
]
;
then
_err
"Record not found."
return
1
fi
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