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
b384a24c
Unverified
Commit
b384a24c
authored
Jul 30, 2023
by
neil
Committed by
GitHub
Jul 30, 2023
Browse files
Merge pull request #4710 from zearan/patch-1
Fix the API calls that get the list of domains that PLESK can manage
parents
dcf3d723
3b7be478
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_pleskxml.sh
View file @
b384a24c
...
@@ -46,6 +46,10 @@ pleskxml_tplt_get_domains="<packet><webspace><get><filter/><dataset><gen_info/><
...
@@ -46,6 +46,10 @@ pleskxml_tplt_get_domains="<packet><webspace><get><filter/><dataset><gen_info/><
# Also used to test credentials and URI.
# Also used to test credentials and URI.
# No params.
# No params.
pleskxml_tplt_get_additional_domains
=
"<packet><site><get><filter/><dataset><gen_info/></dataset></get></site></packet>"
# Get a list of additional domains that PLESK can manage, so we can check root domain + host for acme.sh
# No params.
pleskxml_tplt_get_dns_records
=
"<packet><dns><get_rec><filter><site-id>%s</site-id></filter></get_rec></dns></packet>"
pleskxml_tplt_get_dns_records
=
"<packet><dns><get_rec><filter><site-id>%s</site-id></filter></get_rec></dns></packet>"
# Get all DNS records for a Plesk domain ID.
# Get all DNS records for a Plesk domain ID.
# PARAM = Plesk domain id to query
# PARAM = Plesk domain id to query
...
@@ -375,16 +379,44 @@ _pleskxml_get_root_domain() {
...
@@ -375,16 +379,44 @@ _pleskxml_get_root_domain() {
return
1
return
1
fi
fi
# Generate a crude list of domains known to this Plesk account.
# Generate a crude list of domains known to this Plesk account
based on subscriptions
.
# We convert <ascii-name> tags to <name> so it'll flag on a hit with either <name> or <ascii-name> fields,
# We convert <ascii-name> tags to <name> so it'll flag on a hit with either <name> or <ascii-name> fields,
# for non-Western character sets.
# for non-Western character sets.
# Output will be one line per known domain, containing 2 <name> tages and a single <id> tag
# Output will be one line per known domain, containing 2 <name> tages and a single <id> tag
# We don't actually need to check for type, name, *and* id, but it guarantees only usable lines are returned.
# We don't actually need to check for type, name, *and* id, but it guarantees only usable lines are returned.
output
=
"
$(
_api_response_split
"
$pleskxml_prettyprint_result
"
'result'
'<status>ok</status>'
|
sed
's/<ascii-name>/<name>/g;s/<\/ascii-name>/<\/name>/g'
|
grep
'<name>'
|
grep
'<id>'
)
"
output
=
"
$(
_api_response_split
"
$pleskxml_prettyprint_result
"
'result'
'<status>ok</status>'
|
sed
's/<ascii-name>/<name>/g;s/<\/ascii-name>/<\/name>/g'
|
grep
'<name>'
|
grep
'<id>'
)
"
debug_output
=
"
$(
printf
"%s"
"
$output
"
|
sed
-n
's:.*<name>\(.*\)</name>.*:\1:p'
)
"
_debug
'Domains managed by Plesk server are:'
_debug
"
$debug_output
"
_debug
"Querying Plesk server for list of additional managed domains..."
_call_api
"
$pleskxml_tplt_get_additional_domains
"
if
[
"
$pleskxml_retcode
"
-ne
0
]
;
then
return
1
fi
# Generate a crude list of additional domains known to this Plesk account based on sites.
# We convert <ascii-name> tags to <name> so it'll flag on a hit with either <name> or <ascii-name> fields,
# for non-Western character sets.
# Output will be one line per known domain, containing 2 <name> tages and a single <id> tag
# We don't actually need to check for type, name, *and* id, but it guarantees only usable lines are returned.
output_additional
=
"
$(
_api_response_split
"
$pleskxml_prettyprint_result
"
'result'
'<status>ok</status>'
|
sed
's/<ascii-name>/<name>/g;s/<\/ascii-name>/<\/name>/g'
|
grep
'<name>'
|
grep
'<id>'
)
"
debug_additional
=
"
$(
printf
"%s"
"
$output_additional
"
|
sed
-n
's:.*<name>\(.*\)</name>.*:\1:p'
)
"
_debug
'Additional domains managed by Plesk server are:'
_debug
"
$debug_additional
"
# Concate the two outputs together.
output
=
"
$(
printf
"%s"
"
$output
$NEWLINE
$output_additional
"
)
"
debug_output
=
"
$(
printf
"%s"
"
$output
"
|
sed
-n
's:.*<name>\(.*\)</name>.*:\1:p'
)
"
_debug
'Domains managed by Plesk server are
(ignore the hacked output)
:'
_debug
'Domains
(including additional)
managed by Plesk server are:'
_debug
"
$output
"
_debug
"
$
debug_
output
"
# loop and test if domain, or any parent domain, is managed by Plesk
# loop and test if domain, or any parent domain, is managed by Plesk
# Loop until we don't have any '.' in the string we're testing as a candidate Plesk-managed domain
# Loop until we don't have any '.' in the string we're testing as a candidate Plesk-managed domain
...
...
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