Fix Plesk helper sourcing and add fallback for domain discovery
Problem: When domain-discovery.sh is sourced directly (not via launcher), plesk-helpers.sh wasn't being loaded because $LIB_DIR was undefined. This caused list_all_domains() to fail on Plesk with 'command not found'. Fixes: 1. Enhanced Plesk helper sourcing logic: - Try $LIB_DIR first (when sourced from launcher) - Fall back to $SCRIPT_DIR (when sourced directly) - Ensures plesk-helpers.sh loads in all contexts 2. Added fallback in list_all_domains() for Plesk: - Check if plesk_list_domains function exists - If not available, fall back to directory scan - Scans /var/www/vhosts/ excluding system directories - Ensures domains are found even without plesk-helpers.sh Impact: Domain discovery now works correctly when: - Sourced from launcher (uses plesk-helpers.sh) - Sourced directly from command line (uses fallback) - Plesk CLI unavailable (uses directory scan) Tested on: Plesk 18.0.61 production system
This commit is contained in:
+16
-1
@@ -13,7 +13,14 @@ if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||
fi
|
||||
|
||||
# Source control panel helpers if available
|
||||
[ "$SYS_CONTROL_PANEL" = "plesk" ] && [ -f "$LIB_DIR/plesk-helpers.sh" ] && source "$LIB_DIR/plesk-helpers.sh"
|
||||
if [ "$SYS_CONTROL_PANEL" = "plesk" ]; then
|
||||
# Try LIB_DIR first, then SCRIPT_DIR
|
||||
if [ -n "$LIB_DIR" ] && [ -f "$LIB_DIR/plesk-helpers.sh" ]; then
|
||||
source "$LIB_DIR/plesk-helpers.sh"
|
||||
elif [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/plesk-helpers.sh" ]; then
|
||||
source "$SCRIPT_DIR/plesk-helpers.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
#############################################################################
|
||||
# DOMAIN DISCOVERY (Control Panel Agnostic)
|
||||
@@ -36,7 +43,15 @@ list_all_domains() {
|
||||
;;
|
||||
|
||||
plesk)
|
||||
# Use plesk_list_domains if available, otherwise fallback
|
||||
if type plesk_list_domains >/dev/null 2>&1; then
|
||||
plesk_list_domains
|
||||
else
|
||||
# Fallback: scan vhosts directory
|
||||
ls -1 /var/www/vhosts/ 2>/dev/null | \
|
||||
grep -v "^system$\|^chroot$\|^\.skel$\|^default$\|^fs$" | \
|
||||
grep -v "^\." || true
|
||||
fi
|
||||
;;
|
||||
|
||||
interworx)
|
||||
|
||||
Reference in New Issue
Block a user