@@ -46,6 +46,10 @@ pleskxml_tplt_get_domains="<packet><webspace><get><filter/><dataset><gen_info/><
4646# Also used to test credentials and URI.
4747# No params.
4848
49+ pleskxml_tplt_get_additional_domains=" <packet><site><get><filter/><dataset><gen_info/></dataset></get></site></packet>"
50+ # Get a list of additional domains that PLESK can manage, so we can check root domain + host for acme.sh
51+ # No params.
52+
4953pleskxml_tplt_get_dns_records=" <packet><dns><get_rec><filter><site-id>%s</site-id></filter></get_rec></dns></packet>"
5054# Get all DNS records for a Plesk domain ID.
5155# PARAM = Plesk domain id to query
@@ -375,16 +379,44 @@ _pleskxml_get_root_domain() {
375379 return 1
376380 fi
377381
378- # Generate a crude list of domains known to this Plesk account.
382+ # Generate a crude list of domains known to this Plesk account based on subscriptions .
379383 # We convert <ascii-name> tags to <name> so it'll flag on a hit with either <name> or <ascii-name> fields,
380384 # for non-Western character sets.
381385 # Output will be one line per known domain, containing 2 <name> tages and a single <id> tag
382386 # We don't actually need to check for type, name, *and* id, but it guarantees only usable lines are returned.
383387
384388 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>' ) "
389+ debug_output=" $( printf " %s" " $output " | sed -n ' s:.*<name>\(.*\)</name>.*:\1:p' ) "
390+
391+ _debug ' Domains managed by Plesk server are:'
392+ _debug " $debug_output "
393+
394+ _debug " Querying Plesk server for list of additional managed domains..."
395+
396+ _call_api " $pleskxml_tplt_get_additional_domains "
397+ if [ " $pleskxml_retcode " -ne 0 ]; then
398+ return 1
399+ fi
400+
401+ # Generate a crude list of additional domains known to this Plesk account based on sites.
402+ # We convert <ascii-name> tags to <name> so it'll flag on a hit with either <name> or <ascii-name> fields,
403+ # for non-Western character sets.
404+ # Output will be one line per known domain, containing 2 <name> tages and a single <id> tag
405+ # We don't actually need to check for type, name, *and* id, but it guarantees only usable lines are returned.
406+
407+ 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>' ) "
408+ debug_additional=" $( printf " %s" " $output_additional " | sed -n ' s:.*<name>\(.*\)</name>.*:\1:p' ) "
409+
410+ _debug ' Additional domains managed by Plesk server are:'
411+ _debug " $debug_additional "
412+
413+ # Concate the two outputs together.
414+
415+ output=" $( printf " %s" " $output $NEWLINE $output_additional " ) "
416+ debug_output=" $( printf " %s" " $output " | sed -n ' s:.*<name>\(.*\)</name>.*:\1:p' ) "
385417
386- _debug ' Domains managed by Plesk server are (ignore the hacked output) :'
387- _debug " $output "
418+ _debug ' Domains (including additional) managed by Plesk server are:'
419+ _debug " $debug_output "
388420
389421 # loop and test if domain, or any parent domain, is managed by Plesk
390422 # Loop until we don't have any '.' in the string we're testing as a candidate Plesk-managed domain
0 commit comments