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
80ca6de5
Unverified
Commit
80ca6de5
authored
Feb 22, 2020
by
neil
Committed by
GitHub
Feb 22, 2020
Browse files
Merge pull request #2728 from artooro/master
add support for using a Zone ID
parents
c6c395cd
d43227ed
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_cf.sh
View file @
80ca6de5
...
...
@@ -7,6 +7,7 @@
#CF_Token="xxxx"
#CF_Account_ID="xxxx"
#CF_Zone_ID="xxxx"
CF_Api
=
"https://api.cloudflare.com/client/v4"
...
...
@@ -19,12 +20,14 @@ dns_cf_add() {
CF_Token
=
"
${
CF_Token
:-
$(
_readaccountconf_mutable CF_Token
)
}
"
CF_Account_ID
=
"
${
CF_Account_ID
:-
$(
_readaccountconf_mutable CF_Account_ID
)
}
"
CF_Zone_ID
=
"
${
CF_Zone_ID
:-
$(
_readaccountconf_mutable CF_Zone_ID
)
}
"
CF_Key
=
"
${
CF_Key
:-
$(
_readaccountconf_mutable CF_Key
)
}
"
CF_Email
=
"
${
CF_Email
:-
$(
_readaccountconf_mutable CF_Email
)
}
"
if
[
"
$CF_Token
"
]
;
then
_saveaccountconf_mutable CF_Token
"
$CF_Token
"
_saveaccountconf_mutable CF_Account_ID
"
$CF_Account_ID
"
_saveaccountconf_mutable CF_Zone_ID
"
$CF_Zone_ID
"
else
if
[
-z
"
$CF_Key
"
]
||
[
-z
"
$CF_Email
"
]
;
then
CF_Key
=
""
...
...
@@ -141,6 +144,28 @@ _get_root() {
domain
=
$1
i
=
1
p
=
1
# Use Zone ID directly if provided
if
[
"
$CF_Zone_ID
"
]
;
then
if
!
_cf_rest GET
"zones/
$CF_Zone_ID
"
;
then
return
1
else
if
_contains
"
$response
"
'"success":true'
;
then
_domain
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
name
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
|
head
-n
1
)
if
[
"
$_domain
"
]
;
then
_cutlength
=
$((${#
domain
}
-
${#
_domain
}
-
1
))
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-c
"1-
$_cutlength
"
)
_domain_id
=
$CF_Zone_ID
return
0
else
return
1
fi
else
return
1
fi
fi
fi
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
...
...
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