From 3398e66744f433e0081462d647eef9dc9e970a55 Mon Sep 17 00:00:00 2001 From: cschantz Date: Tue, 23 Dec 2025 20:50:00 -0500 Subject: [PATCH] Fix WordPress path parsing for multi-panel support in reference-db.sh Problem: User reported launcher showing "0 0 domains", "0 0 users", "0 0 databases" on Plesk server after pulling from git. Root cause was build_wordpress_section() in reference-db.sh assuming cPanel-only directory structure. Changes to lib/reference-db.sh: 1. WordPress Username/Domain Extraction (lines 282-304): - OLD: Hardcoded /home/username/ path extraction - NEW: Panel-agnostic case statement: * cPanel: Extract from /home/username/ * Plesk: Extract domain from /var/www/vhosts/domain.com/, get owner via get_domain_owner() * InterWorx: Extract from /chroot/home/user/var/domain.com/ * Standalone: Use stat -c "%U" to get filesystem owner 2. cPanel Domain Inference (lines 306-322): - Moved cPanel-specific path parsing inside conditional - Only runs if domain not already set AND on cPanel - Removed duplicate "local domain=" declaration Impact: WordPress section in system reference database will now correctly identify WordPress installations on Plesk (/var/www/vhosts/) and InterWorx (/chroot/home/) servers, not just cPanel (/home/). Related Commits: - 589247d: Fixed build_domains_section() to use unified discovery - 0984e76: Fixed domain-discovery.sh Plesk helper sourcing Status: READY FOR TESTING ON PLESK SERVER Remaining Work: Comprehensive audit found 13 additional modules with cPanel-specific code that need similar multi-panel support. See /tmp/plesk-migration-status.md for full migration plan and recommendations. --- lib/reference-db.sh | 54 +++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/reference-db.sh b/lib/reference-db.sh index 87c4163..780046e 100644 --- a/lib/reference-db.sh +++ b/lib/reference-db.sh @@ -279,24 +279,46 @@ build_wordpress_section() { for wp_config in $wp_configs; do local wp_dir=$(dirname "$wp_config") - # Extract username from path (/home/username/...) - local username=$(echo "$wp_dir" | cut -d'/' -f3) - - # Try to get domain from path - check if it's in a subdomain or addon domain folder - local path_after_home=$(echo "$wp_dir" | sed "s|^/home/$username/||") + # Extract username/domain from path (panel-agnostic) + local username="" local domain="" - # Check for common domain folder patterns - if [[ "$path_after_home" == public_html ]]; then - # This is the primary domain - get it from user info - domain=$(grep "USER|${username}|" "$SYSREF_DB" 2>/dev/null | cut -d'|' -f3 || true) - elif [[ "$path_after_home" =~ ^public_html/(.+) ]]; then - # Could be subdomain or subdirectory - extract folder name - local folder=$(echo "$path_after_home" | cut -d'/' -f2) - domain="${folder}" - else - # Might be addon/parked domain with own directory - domain=$(echo "$path_after_home" | cut -d'/' -f1) + case "$SYS_CONTROL_PANEL" in + cpanel) + # cPanel: /home/username/... + username=$(echo "$wp_dir" | cut -d'/' -f3) + ;; + plesk) + # Plesk: /var/www/vhosts/domain.com/... + domain=$(echo "$wp_dir" | cut -d'/' -f5) + username=$(get_domain_owner "$domain" 2>/dev/null || echo "unknown") + ;; + interworx) + # InterWorx: /chroot/home/user/var/domain.com/... + username=$(echo "$wp_dir" | cut -d'/' -f4) + ;; + *) + # Standalone: try to extract from path + username=$(stat -c "%U" "$wp_dir" 2>/dev/null || echo "unknown") + ;; + esac + + # If domain not set yet (cPanel/InterWorx/Standalone), try to infer from path + if [ -z "$domain" ] && [ "$SYS_CONTROL_PANEL" = "cpanel" ]; then + # cPanel: check if this is primary domain or addon/subdomain + local path_after_home=$(echo "$wp_dir" | sed "s|^/home/$username/||") + + if [[ "$path_after_home" == public_html ]]; then + # This is the primary domain - get it from user info + domain=$(grep "USER|${username}|" "$SYSREF_DB" 2>/dev/null | cut -d'|' -f3 || true) + elif [[ "$path_after_home" =~ ^public_html/(.+) ]]; then + # Could be subdomain or subdirectory - extract folder name + local folder=$(echo "$path_after_home" | cut -d'/' -f2) + domain="${folder}" + else + # Might be addon/parked domain with own directory + domain=$(echo "$path_after_home" | cut -d'/' -f1) + fi fi # Try to get actual domain from WP database options (more reliable)