Improve Maldet installation error handling and diagnostics
Problem: - Maldet installation was failing silently on Plesk servers - No error output to diagnose issues (./install.sh &>/dev/null) - Users only saw "✗ Maldet installation failed" with no context Changes: - Add comprehensive error capture to /tmp/maldet-install-$$.log - Show last 10 lines of installation output on failure - Add step-by-step progress indicators (download, extract, install) - Check each operation and fail fast with clear error messages - Add Plesk-specific diagnostics: • Detect Plesk installation • Check cron directory permissions • Verify /usr/local/sbin exists - Preserve full log file for detailed investigation - Return proper exit codes for error handling This enables users to diagnose and fix Plesk-specific installation issues instead of being stuck with a generic failure message.
This commit is contained in:
@@ -218,26 +218,84 @@ install_all_scanners() {
|
|||||||
if ! is_maldet_installed; then
|
if ! is_maldet_installed; then
|
||||||
echo -e "${CYAN}[2/4] Installing Maldet...${NC}"
|
echo -e "${CYAN}[2/4] Installing Maldet...${NC}"
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp || { echo -e "${RED}✗ Cannot access /tmp${NC}"; return 1; }
|
||||||
wget -q http://www.rfxn.com/downloads/maldetect-current.tar.gz
|
|
||||||
|
|
||||||
if [ -f maldetect-current.tar.gz ]; then
|
# Download Maldet
|
||||||
tar -xzf maldetect-current.tar.gz
|
echo " → Downloading Maldet..."
|
||||||
cd maldetect-* 2>/dev/null
|
if ! wget -q http://www.rfxn.com/downloads/maldetect-current.tar.gz; then
|
||||||
./install.sh &>/dev/null
|
echo -e "${RED}✗ Download failed - check internet connectivity${NC}"
|
||||||
cd /tmp
|
return 1
|
||||||
rm -rf "maldetect-"*
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_maldet_installed; then
|
if [ -f maldetect-current.tar.gz ]; then
|
||||||
echo -e "${GREEN}✓ Maldet installed${NC}"
|
echo " → Extracting archive..."
|
||||||
|
if ! tar -xzf maldetect-current.tar.gz 2>/dev/null; then
|
||||||
|
echo -e "${RED}✗ Extraction failed - archive may be corrupted${NC}"
|
||||||
|
rm -f maldetect-current.tar.gz
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Update malware signatures immediately
|
# Change to extracted directory
|
||||||
echo " → Updating malware signatures..."
|
if ! cd maldetect-* 2>/dev/null; then
|
||||||
maldet -u 2>&1 | grep -E "update completed|signatures" || maldet -u &>/dev/null
|
echo -e "${RED}✗ Cannot find extracted directory${NC}"
|
||||||
echo -e " ${GREEN}✓${NC} Signatures updated"
|
cd /tmp
|
||||||
|
rm -rf "maldetect-"*
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run installation with error capture
|
||||||
|
echo " → Running installation script..."
|
||||||
|
local install_log="/tmp/maldet-install-$$.log"
|
||||||
|
if ./install.sh > "$install_log" 2>&1; then
|
||||||
|
install_exit=0
|
||||||
|
else
|
||||||
|
install_exit=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
cd /tmp
|
||||||
|
rm -rf "maldetect-"*
|
||||||
|
|
||||||
|
# Check if installation succeeded
|
||||||
|
if is_maldet_installed; then
|
||||||
|
echo -e "${GREEN}✓ Maldet installed${NC}"
|
||||||
|
rm -f "$install_log"
|
||||||
|
|
||||||
|
# Update malware signatures immediately
|
||||||
|
echo " → Updating malware signatures..."
|
||||||
|
maldet -u 2>&1 | grep -E "update completed|signatures" || maldet -u &>/dev/null
|
||||||
|
echo -e " ${GREEN}✓${NC} Signatures updated"
|
||||||
|
else
|
||||||
|
echo -e "${RED}✗ Maldet installation failed${NC}"
|
||||||
|
|
||||||
|
# Show diagnostic information
|
||||||
|
if [ -f "$install_log" ]; then
|
||||||
|
echo -e "${YELLOW}Installation output (last 10 lines):${NC}"
|
||||||
|
tail -10 "$install_log" | sed 's/^/ /'
|
||||||
|
echo ""
|
||||||
|
echo -e "${YELLOW}Full log saved to: $install_log${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for common Plesk issues
|
||||||
|
if command -v plesk >/dev/null 2>&1; then
|
||||||
|
echo -e "${YELLOW}Detected Plesk system - checking for conflicts...${NC}"
|
||||||
|
|
||||||
|
# Check if cron is accessible
|
||||||
|
if [ ! -w /var/spool/cron ] && [ ! -w /etc/cron.d ]; then
|
||||||
|
echo " → Cron directory permissions may be restricted"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if required directories exist
|
||||||
|
if [ ! -d /usr/local/sbin ]; then
|
||||||
|
echo " → /usr/local/sbin does not exist (required for maldet)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}✗ Maldet installation failed${NC}"
|
echo -e "${RED}✗ Download failed - maldetect-current.tar.gz not found${NC}"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${GREEN}✓ Maldet already installed${NC}"
|
echo -e "${GREEN}✓ Maldet already installed${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user