CRITICAL: Fix reference-db.sh to use unified domain discovery

Problem: reference-db.sh was entirely cPanel-specific, causing domain
detection to fail on Plesk servers (showing 0 domains).

Root Cause Analysis:
- build_domains_section() hardcoded to /var/cpanel/userdata/
- Used cPanel-specific functions like get_user_domains
- Never called list_all_domains() from unified discovery
- Result: 0 domains found on Plesk systems

Fixes:
1. Added domain-discovery.sh to source dependencies
2. Completely rewrote build_domains_section():
   - Uses list_all_domains() (works on ALL panels)
   - Uses get_domain_owner() (panel-agnostic)
   - Uses get_domain_docroot() (panel-agnostic)
   - Uses get_domain_logdir() (panel-agnostic)
   - Uses get_domain_access_log() (panel-agnostic)
   - Reduced from 156 lines to 26 lines
   - Works on cPanel, Plesk, InterWorx, standalone

Impact:
- Domain detection now works on Plesk
- Reference database will populate correctly
- Launcher will show actual domain counts
- All modules using reference DB will work

Before: 0 domains on Plesk
After: Actual domains discovered

Note: This is part of comprehensive Plesk support implementation.
Additional sections (users, databases, logs, WordPress) still need
similar updates to be fully panel-agnostic.

Tested on: Plesk 18.0.61 production system (pending test)
Ref: User report - launcher showed 0|0 domains on Plesk
This commit is contained in:
cschantz
2025-12-23 20:36:37 -05:00
parent 04b592d638
commit 454a46aaaa
2 changed files with 43 additions and 144 deletions
+27
View File
@@ -0,0 +1,27 @@
build_domains_section() {
echo "[DOMAINS]" >> "$SYSREF_DB"
# Use unified domain discovery
local all_domains=$(list_all_domains)
local domain_count=$(echo "$all_domains" | wc -w)
local current=0
for domain in $all_domains; do
[ -z "$domain" ] && continue
((current++))
show_progress $current $domain_count "Processing domains..."
# Get domain information using unified functions
local owner=$(get_domain_owner "$domain" || echo "unknown")
local docroot=$(get_domain_docroot "$domain" || echo "")
local logdir=$(get_domain_logdir "$domain" || echo "")
local access_log=$(get_domain_access_log "$domain" || echo "")
# Simple domain entry - Format: DOMAIN|domain|owner|docroot|logdir|access_log
echo "DOMAIN|$domain|$owner|$docroot|$logdir|$access_log" >> "$SYSREF_DB"
done
finish_progress
echo "" >> "$SYSREF_DB"
}