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.
This commit is contained in:
+38
-16
@@ -279,24 +279,46 @@ build_wordpress_section() {
|
|||||||
for wp_config in $wp_configs; do
|
for wp_config in $wp_configs; do
|
||||||
local wp_dir=$(dirname "$wp_config")
|
local wp_dir=$(dirname "$wp_config")
|
||||||
|
|
||||||
# Extract username from path (/home/username/...)
|
# Extract username/domain from path (panel-agnostic)
|
||||||
local username=$(echo "$wp_dir" | cut -d'/' -f3)
|
local username=""
|
||||||
|
|
||||||
# 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/||")
|
|
||||||
local domain=""
|
local domain=""
|
||||||
|
|
||||||
# Check for common domain folder patterns
|
case "$SYS_CONTROL_PANEL" in
|
||||||
if [[ "$path_after_home" == public_html ]]; then
|
cpanel)
|
||||||
# This is the primary domain - get it from user info
|
# cPanel: /home/username/...
|
||||||
domain=$(grep "USER|${username}|" "$SYSREF_DB" 2>/dev/null | cut -d'|' -f3 || true)
|
username=$(echo "$wp_dir" | cut -d'/' -f3)
|
||||||
elif [[ "$path_after_home" =~ ^public_html/(.+) ]]; then
|
;;
|
||||||
# Could be subdomain or subdirectory - extract folder name
|
plesk)
|
||||||
local folder=$(echo "$path_after_home" | cut -d'/' -f2)
|
# Plesk: /var/www/vhosts/domain.com/...
|
||||||
domain="${folder}"
|
domain=$(echo "$wp_dir" | cut -d'/' -f5)
|
||||||
else
|
username=$(get_domain_owner "$domain" 2>/dev/null || echo "unknown")
|
||||||
# Might be addon/parked domain with own directory
|
;;
|
||||||
domain=$(echo "$path_after_home" | cut -d'/' -f1)
|
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
|
fi
|
||||||
|
|
||||||
# Try to get actual domain from WP database options (more reliable)
|
# Try to get actual domain from WP database options (more reliable)
|
||||||
|
|||||||
Reference in New Issue
Block a user