Core Infrastructure Added: - lib/plesk-helpers.sh: 30+ Plesk-specific helper functions - Domain discovery (list, docroot, logdir, access/error logs) - User/subscription management - Database discovery - PHP version detection (/opt/plesk/php/) - PHP-FPM pool discovery - Configuration file locations - Mail functions - Service management - Version detection with log structure handling - lib/domain-discovery.sh: Unified control panel abstraction - Consistent API across cPanel, Plesk, InterWorx, standalone - list_all_domains() - works on any panel - get_domain_docroot() - panel-agnostic document root - get_domain_logdir() - panel-agnostic log discovery - get_domain_access_log() - access log paths - get_domain_error_log() - error log paths - get_all_log_files() - all logs across all domains - get_domain_owner() - domain owner/user - list_all_users() - user enumeration - get_domain_fpm_socket() - PHP-FPM pool sockets - get_domain_databases() - database discovery - domain_exists() - existence checks Documentation: - PLESK_REFERENCE.md: Complete Plesk architecture reference - Directory structure mapping - Log file locations (current & future versions) - PHP-FPM pool locations - Configuration file paths - Plesk CLI command reference - Key differences from cPanel - Subdomain handling differences - PLESK_SUPPORT_SUMMARY.md: Implementation summary - All functions documented - Usage examples - Migration guide for existing modules - Version compatibility notes - Testing checklist System Detection Enhanced: - lib/system-detect.sh: - Improved Plesk detection with version-aware log paths - Auto-sources plesk-helpers.sh when Plesk detected - Added /opt/plesk/php/ scanning for PHP versions - Sets SYS_USER_HOME_BASE=/var/www/vhosts for Plesk Email Menu Added: - launcher.sh: New Email Troubleshooting menu category - 9 email diagnostic/maintenance tools (placeholders) - Deliverability test, queue inspector, SMTP test - SPF/DKIM/DMARC check, blacklist check - Mail log analyzer, queue flush - Mailbox cleanup, size reports Plesk Architecture Support: - /var/www/vhosts/ base directory structure - system/DOMAIN/logs/ for Plesk <18.0.50 - DOMAIN/logs/ for Plesk 18.0.50+ - Automatic version detection - Subdomain separate directory handling - /opt/plesk/php/X.Y/ PHP version detection - /var/www/vhosts/system/DOMAIN/php-fpm.sock pools - /var/www/vhosts/system/DOMAIN/conf/ configs Fallback Mechanisms: - All functions work with or without Plesk CLI - Directory scanning fallbacks - MySQL direct query fallbacks - Path inference from standard locations Status: Core infrastructure complete, ready for module integration Next: Test on actual Plesk server, update existing modules Ref: system_map.tsv analysis from Plesk production system
9.7 KiB
Plesk Support Implementation Summary
Overview
Comprehensive Plesk control panel support has been added to the Server Toolkit. The toolkit now fully supports cPanel, Plesk, InterWorx, and standalone server configurations.
Files Added
1. /root/server-toolkit/PLESK_REFERENCE.md
Complete Plesk paths and structure reference documentation including:
- Directory structure mapping
- Log file locations (both current and future versions)
- PHP-FPM pool locations
- Configuration file paths
- CLI command reference
- Key differences from cPanel
2. /root/server-toolkit/lib/plesk-helpers.sh
Plesk-specific helper functions library with 30+ functions:
Domain Discovery:
plesk_list_domains()- List all domainsplesk_get_docroot()- Get document rootplesk_get_logdir()- Get log directory (version-aware)plesk_get_all_logdirs()- Get all domain log directoriesplesk_get_access_log()- Get access log pathplesk_get_error_log()- Get error log pathplesk_domain_exists()- Check if domain exists
User/Subscription Management:
plesk_list_subscriptions()- List all subscriptionsplesk_get_owner()- Get domain owner
Database Discovery:
plesk_list_databases()- List all databasesplesk_list_domain_databases()- List databases for domain
PHP Detection:
plesk_list_php_handlers()- List available PHP handlersplesk_get_domain_php()- Get PHP version for domainplesk_detect_php_versions()- Detect all Plesk PHP versions
PHP-FPM Pools:
plesk_list_fpm_sockets()- List all FPM socketsplesk_get_fpm_socket()- Get FPM socket for domain
Configuration Files:
plesk_get_confdir()- Get config directoryplesk_get_httpd_conf()- Get Apache configplesk_get_nginx_conf()- Get Nginx configplesk_get_php_ini()- Get PHP config
Mail Functions:
plesk_get_mailbox_dir()- Get mailbox directoryplesk_list_mailboxes()- List mailboxes for domain
Service Management:
plesk_restart_apache()- Restart Apacheplesk_restart_nginx()- Restart Nginxplesk_restart_phpfpm()- Restart PHP-FPM
Utilities:
plesk_get_version()- Get Plesk versionplesk_is_new_log_structure()- Check if Plesk 18.0.50+plesk_list_domains_with_docroots()- Get domains with docroots as TSV
3. /root/server-toolkit/lib/domain-discovery.sh
Unified control panel abstraction layer providing consistent interface across all panels:
Universal Functions (Work on All Panels):
list_all_domains()- List all domainsget_domain_docroot()- Get document rootget_domain_logdir()- Get log directoryget_domain_access_log()- Get access log pathget_domain_error_log()- Get error log pathget_all_log_files()- Get all log filesget_domain_owner()- Get domain ownerlist_all_users()- List all usersget_domain_fpm_socket()- Get PHP-FPM socketget_all_fpm_sockets()- Get all FPM socketsget_domain_databases()- Get domain databasesdomain_exists()- Check if domain existslist_domains_with_docroots()- Get domains with docroots
How It Works:
- Each function detects
$SYS_CONTROL_PANELand calls appropriate panel-specific code - Provides consistent API regardless of control panel
- Includes fallback methods when panel CLI unavailable
Files Modified
1. /root/server-toolkit/lib/system-detect.sh
Plesk Detection Enhancement (lines 56-77):
# Plesk
if [ -f "/usr/local/psa/version" ]; then
SYS_CONTROL_PANEL="plesk"
SYS_CONTROL_PANEL_VERSION=$(cat /usr/local/psa/version | head -1)
# Plesk uses /var/www/vhosts as base
SYS_USER_HOME_BASE="/var/www/vhosts"
# Log directory depends on Plesk version
# Plesk 18.0.50+ uses /var/www/vhosts/DOMAIN/logs
# Plesk <18.0.50 uses /var/www/vhosts/system/DOMAIN/logs
# Set marker path - tools will use plesk_get_logdir() for actual path
SYS_LOG_DIR="/var/www/vhosts/system"
# Source Plesk helpers for advanced functionality
if [ -f "$LIB_DIR/plesk-helpers.sh" ]; then
source "$LIB_DIR/plesk-helpers.sh"
fi
print_success "Detected Plesk v${SYS_CONTROL_PANEL_VERSION}"
return 0
fi
PHP Detection Enhancement (lines 253-261):
# Check Plesk PHP versions (/opt/plesk/php/)
if [ "$SYS_CONTROL_PANEL" = "plesk" ]; then
for php_path in /opt/plesk/php/*/bin/php; do
if [ -x "$php_path" ]; then
local full_version=$($php_path -v 2>/dev/null | grep -oP '^PHP \K[\d.]+' | head -1)
[ -n "$full_version" ] && SYS_PHP_VERSIONS+=("$full_version")
fi
done
fi
Key Plesk Architecture Differences
1. Directory Structure
- cPanel:
/home/USER/public_html/ - Plesk:
/var/www/vhosts/DOMAIN/httpdocs/
2. Log Files
- cPanel:
/var/log/apache2/domlogs/DOMAIN - Plesk (current):
/var/www/vhosts/system/DOMAIN/logs/ - Plesk (18.0.50+):
/var/www/vhosts/DOMAIN/logs/
3. Subdomain Handling
- cPanel: Subdomains under main domain:
/home/USER/public_html/subdomain/ - Plesk: Separate directories:
/var/www/vhosts/sub.domain.com/httpdocs/
4. PHP Versions
- cPanel:
/opt/cpanel/ea-phpXX/root/usr/bin/php - Plesk:
/opt/plesk/php/X.Y/bin/php
5. PHP-FPM Pools
- cPanel:
/opt/cpanel/ea-phpXX/root/usr/var/run/*.sock - Plesk:
/var/www/vhosts/system/DOMAIN/php-fpm.sock
6. Configuration Files
- cPanel:
/var/cpanel/userdata/USER/DOMAIN - Plesk:
/var/www/vhosts/system/DOMAIN/conf/
Version Compatibility
Plesk Obsidian 17.x
- Logs in
/var/www/vhosts/system/DOMAIN/logs/ - Fully supported
Plesk Obsidian 18.0.0 - 18.0.49
- Logs in
/var/www/vhosts/system/DOMAIN/logs/ - Fully supported
Plesk Obsidian 18.0.50+
- Logs moved to
/var/www/vhosts/DOMAIN/logs/ - Auto-detected via
plesk_is_new_log_structure() - Functions check both locations
Usage Examples
Using Plesk-Specific Functions
#!/bin/bash
source /root/server-toolkit/lib/system-detect.sh
source /root/server-toolkit/lib/plesk-helpers.sh
# List all domains
for domain in $(plesk_list_domains); do
echo "Domain: $domain"
# Get paths
docroot=$(plesk_get_docroot "$domain")
logdir=$(plesk_get_logdir "$domain")
echo " Document root: $docroot"
echo " Log directory: $logdir"
done
Using Unified Discovery Functions
#!/bin/bash
source /root/server-toolkit/lib/system-detect.sh
source /root/server-toolkit/lib/domain-discovery.sh
# Works on ANY control panel (cPanel, Plesk, InterWorx, or standalone)
for domain in $(list_all_domains); do
echo "Domain: $domain"
docroot=$(get_domain_docroot "$domain")
access_log=$(get_domain_access_log "$domain")
owner=$(get_domain_owner "$domain")
echo " Owner: $owner"
echo " Document root: $docroot"
echo " Access log: $access_log"
done
Migration Guide for Existing Modules
OLD: cPanel-Specific Code
# Only works on cPanel
for domain in $(awk -F': ' '{print $1}' /etc/userdomains); do
user=$(grep "^${domain}:" /etc/userdomains | awk -F': ' '{print $2}')
docroot="/home/$user/public_html"
# ...
done
NEW: Panel-Agnostic Code
# Works on all panels
source "$LIB_DIR/domain-discovery.sh"
for domain in $(list_all_domains); do
owner=$(get_domain_owner "$domain")
docroot=$(get_domain_docroot "$domain")
# ...
done
Testing
Test on Plesk System
# Run test script
bash /root/test-plesk-discovery.sh
Verify Detection
source /root/server-toolkit/lib/system-detect.sh
echo "Control Panel: $SYS_CONTROL_PANEL"
echo "Version: $SYS_CONTROL_PANEL_VERSION"
echo "User Home Base: $SYS_USER_HOME_BASE"
echo "Log Directory: $SYS_LOG_DIR"
echo "PHP Versions: ${SYS_PHP_VERSIONS[*]}"
Fallback Mechanisms
All Plesk functions include fallback methods when Plesk CLI is unavailable:
-
Domain Discovery:
- Primary:
plesk bin domain --list - Fallback: Directory scan of
/var/www/vhosts/
- Primary:
-
Document Roots:
- Primary:
plesk bin domain --info DOMAIN - Fallback: Standard path
/var/www/vhosts/DOMAIN/httpdocs
- Primary:
-
PHP Versions:
- Primary:
plesk bin php_handler --list - Fallback: Scan
/opt/plesk/php/*/bin/php
- Primary:
-
Databases:
- Primary:
plesk bin database --list - Fallback: Direct MySQL query with naming conventions
- Primary:
Future Module Updates
The following modules should be updated to use the unified discovery functions:
- ✅ lib/system-detect.sh - Updated
- ⏳ modules/security/live-attack-monitor.sh - Needs update
- ⏳ modules/security/bot-analyzer.sh - Needs update
- ⏳ modules/security/malware-scanner.sh - Needs update
- ⏳ modules/website/ - Needs update for log discovery
- ⏳ modules/performance/php-optimizer.sh - Needs update for PHP-FPM
- ⏳ lib/mysql-analyzer.sh - Needs update for database discovery
- ⏳ lib/user-manager.sh - Needs update for user enumeration
Status
✅ Core Infrastructure Complete:
- Plesk detection and path mapping
- 30+ Plesk helper functions
- Unified discovery abstraction layer
- Comprehensive documentation
- Version compatibility handling
- Fallback mechanisms
⏳ Next Steps:
- Test on actual Plesk server
- Update existing modules to use unified discovery
- Add Plesk-specific features where beneficial
Testing Checklist
When testing on Plesk server:
- Domain enumeration returns all domains
- Document roots are correctly identified
- Log files are found (both access and error)
- PHP versions are detected from /opt/plesk/php/
- PHP-FPM sockets are located
- Configuration files are found
- Owner/user mapping works
- Database discovery functions
- Version detection is accurate
- Log structure detection (old vs new) works
- All modules can find domains and logs