From 8a2d9f5eec3aea8fe1fda483114fc2d7bd0af917 Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 19 Nov 2025 20:08:31 -0500 Subject: [PATCH] REFACTOR: Class D modules - Panel-specific conditionals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completed Class D refactoring (panel-specific modules). MODULES REFACTORED: 1. enable-cphulk.sh (ALREADY COMPLIANT) - Already checks SYS_CONTROL_PANEL at startup (line 35) - Exits gracefully if not cPanel - Shows detected panel in error message - All whmapi1 calls only reachable after panel check - No changes needed ✅ 2. system-health-check.sh (ENHANCED) - Already had conditional checks for CPHulk (lines 606, 1706) - Enhanced control panel version detection (line 940-947) - Now uses SYS_CONTROL_PANEL_VERSION from system-detect.sh - Supports cPanel, Plesk, InterWorx version reporting - All panel-specific features properly gated ARCHITECTURE COMPLIANCE: ✅ Panel-specific features wrapped in conditionals ✅ Graceful degradation when feature unavailable ✅ Clear error messages mentioning panel requirements ✅ Uses system-detect.sh variables ✅ All syntax validated VERIFIED COMPLIANT: ✅ mysql-query-analyzer.sh - Already uses get_user_databases() TESTING: - Both modules passed `bash -n` syntax check - enable-cphulk.sh will exit gracefully on non-cPanel - system-health-check.sh will skip cPanel features on other panels PROGRESS UPDATE: - Class A: ✅ 7 modules (no changes needed) - Class B: ✅ 6/6 modules COMPLETE - Class C: ✅ 3/6 modules (bot-analyzer, malware-scanner, mysql-query) - Class D: ✅ 2/2 modules COMPLETE - Acronis: ✅ 13 modules (no changes needed) Total: 31/38 modules architecture-compliant! Remaining: 7 modules (website error analyzers + WordPress) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/diagnostics/system-health-check.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/diagnostics/system-health-check.sh b/modules/diagnostics/system-health-check.sh index a081b5f..52a4960 100755 --- a/modules/diagnostics/system-health-check.sh +++ b/modules/diagnostics/system-health-check.sh @@ -937,12 +937,13 @@ System may be vulnerable" \ fi fi - # Check for cPanel updates (if cPanel) - if [ -f "/usr/local/cpanel/version" ]; then - local cpanel_version=$(cat /usr/local/cpanel/version) - # Note: We can't easily check if update is available without WHM API - # Just record the version - echo "cPanel version: $cpanel_version" >> "$TEMP_DIR/system_info.txt" + # Check for control panel version + if [ "$SYS_CONTROL_PANEL" = "cpanel" ] && [ -n "$SYS_CONTROL_PANEL_VERSION" ]; then + echo "cPanel version: $SYS_CONTROL_PANEL_VERSION" >> "$TEMP_DIR/system_info.txt" + elif [ "$SYS_CONTROL_PANEL" = "plesk" ] && [ -n "$SYS_CONTROL_PANEL_VERSION" ]; then + echo "Plesk version: $SYS_CONTROL_PANEL_VERSION" >> "$TEMP_DIR/system_info.txt" + elif [ "$SYS_CONTROL_PANEL" = "interworx" ] && [ -n "$SYS_CONTROL_PANEL_VERSION" ]; then + echo "InterWorx version: $SYS_CONTROL_PANEL_VERSION" >> "$TEMP_DIR/system_info.txt" fi }