Add comprehensive Plesk control panel support

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
This commit is contained in:
cschantz
2025-12-23 20:20:09 -05:00
parent 56879cadb5
commit 3471ee3dca
6 changed files with 1672 additions and 6 deletions
+58 -3
View File
@@ -93,10 +93,11 @@ show_main_menu() {
echo -e " ${BLUE}3)${NC} 🌐 Website Diagnostics"
echo -e " ${MAGENTA}4)${NC} 🔧 Performance & Maintenance"
echo -e " ${YELLOW}5)${NC} 💾 Backup & Recovery"
echo -e " ${CYAN}6)${NC} 📧 Email Troubleshooting"
echo ""
echo -e "${BOLD}System:${NC}"
echo ""
echo -e " ${YELLOW}6)${NC} 🗑️ Cleanup Toolkit Data - Clear cached data"
echo -e " ${YELLOW}7)${NC} 🗑️ Cleanup Toolkit Data - Clear cached data"
echo ""
echo -e " ${RED}0)${NC} Exit"
echo ""
@@ -388,12 +389,65 @@ handle_acronis_menu() {
done
}
#############################################################################
# EMAIL TROUBLESHOOTING & MAINTENANCE
#############################################################################
show_email_menu() {
show_banner
echo -e "${CYAN}${BOLD}📧 Email Troubleshooting & Maintenance${NC}"
echo ""
echo -e "${BOLD}Diagnostics:${NC}"
echo ""
echo -e " ${CYAN}1)${NC} 📬 Email Deliverability Test - Test sending/receiving"
echo -e " ${CYAN}2)${NC} 🔍 Mail Queue Inspector - View stuck emails"
echo -e " ${CYAN}3)${NC} 📊 SMTP Connection Test - Verify mail server"
echo -e " ${CYAN}4)${NC} 🔐 SPF/DKIM/DMARC Check - Email authentication"
echo ""
echo -e "${BOLD}Troubleshooting:${NC}"
echo ""
echo -e " ${YELLOW}5)${NC} 🚫 Blacklist Check - Check IP reputation"
echo -e " ${YELLOW}6)${NC} 📧 Mail Log Analyzer - Search mail logs"
echo -e " ${YELLOW}7)${NC} 🔄 Flush Mail Queue - Clear stuck emails"
echo ""
echo -e "${BOLD}Maintenance:${NC}"
echo ""
echo -e " ${GREEN}8)${NC} 🧹 Clean Mailboxes - Remove old emails"
echo -e " ${GREEN}9)${NC} 📈 Mailbox Size Report - Show usage per account"
echo ""
echo -e " ${RED}0)${NC} Back to Main Menu"
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo -n "Select option: "
}
handle_email_menu() {
while true; do
show_email_menu
read -r choice
case $choice in
1) run_module "email" "deliverability-test.sh" ;;
2) run_module "email" "mail-queue-inspector.sh" ;;
3) run_module "email" "smtp-connection-test.sh" ;;
4) run_module "email" "spf-dkim-dmarc-check.sh" ;;
5) run_module "email" "blacklist-check.sh" ;;
6) run_module "email" "mail-log-analyzer.sh" ;;
7) run_module "email" "flush-mail-queue.sh" ;;
8) run_module "email" "clean-mailboxes.sh" ;;
9) run_module "email" "mailbox-size-report.sh" ;;
0) return ;;
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
esac
done
}
#############################################################################
# INITIALIZATION
#############################################################################
init_directories() {
mkdir -p "$MODULES_DIR"/{security,website,performance,backup,diagnostics,maintenance}
mkdir -p "$MODULES_DIR"/{security,website,performance,backup,diagnostics,maintenance,email}
mkdir -p "$LIB_DIR" "$CONFIG_DIR" "$BASE_DIR/logs"
touch "$CONFIG_DIR/whitelist-ips.txt" 2>/dev/null
touch "$CONFIG_DIR/whitelist-user-agents.txt" 2>/dev/null
@@ -457,7 +511,8 @@ main() {
3) handle_website_menu ;;
4) handle_performance_menu ;;
5) handle_backup_menu ;;
6) run_module "maintenance" "cleanup-toolkit-data.sh" ;;
6) handle_email_menu ;;
7) run_module "maintenance" "cleanup-toolkit-data.sh" ;;
0)
echo ""
read -p "Clean history and remove traces? (yes/no): " clean_hist