CRITICAL FIX: Make Maldet installation non-fatal - continue if installation fails

FIXED:
- Wrapped Maldet installation in subshell with '|| true' error handling
- Changed return 1 to return 0 in Maldet installation checks
- Allows installation to continue to RKHunter/ImunifyAV even if Maldet fails
- Changed all Plesk diagnostic returns to just continue

BEHAVIOR CHANGE:
- Before: One scanner failure → entire installation stops with exit code 1
- After: One scanner failure → shows error but continues to next scanner
- User gets all successfully installed scanners even if some fail

This ensures that if Maldet fails to install (e.g., file not created despite
successful installation script), the user can still get ClamAV, ImunifyAV,
and RKHunter installed instead of failing completely.
This commit is contained in:
Developer
2026-03-21 01:27:37 -04:00
parent 4a2581581e
commit 39ead39988
+66 -82
View File
@@ -260,99 +260,83 @@ 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 || { echo -e "${RED}✗ Cannot access /tmp${NC}"; return 1; } (
cd /tmp || { echo -e "${RED}✗ Cannot access /tmp${NC}"; return 1; }
# Download Maldet # Download Maldet
echo " → Downloading Maldet..." echo " → Downloading Maldet..."
if ! wget -q http://www.rfxn.com/downloads/maldetect-current.tar.gz; then if ! wget -q http://www.rfxn.com/downloads/maldetect-current.tar.gz; then
echo -e "${RED}✗ Download failed - check internet connectivity${NC}" echo -e "${RED}✗ Download failed - check internet connectivity${NC}"
return 1
fi
if [ -f maldetect-current.tar.gz ]; then
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 return 1
fi fi
# Find the extracted directory if [ -f maldetect-current.tar.gz ]; then
local maldet_dir=$(find /tmp -maxdepth 1 -type d -name "maldetect-*" 2>/dev/null | head -1) echo " → Extracting archive..."
if [ -z "$maldet_dir" ]; then if ! tar -xzf maldetect-current.tar.gz 2>/dev/null; then
echo -e "${RED}Cannot find extracted directory${NC}" echo -e "${RED}Extraction failed - archive may be corrupted${NC}"
echo " Available directories in /tmp:" rm -f maldetect-current.tar.gz
ls -la /tmp | grep maldetect | sed 's/^/ /' return 1
cd /tmp fi
rm -rf "maldetect-"*
return 1
fi
# Change to extracted directory # Find the extracted directory
if ! cd "$maldet_dir"; then local maldet_dir=$(find /tmp -maxdepth 1 -type d -name "maldetect-*" 2>/dev/null | head -1)
echo -e "${RED}✗ Cannot access directory: $maldet_dir${NC}" if [ -z "$maldet_dir" ]; then
cd /tmp echo -e "${RED}✗ Cannot find extracted directory${NC}"
rm -rf "maldetect-"* cd /tmp
return 1 rm -rf "maldetect-"*
fi return 1
fi
# Run installation with error capture # Change to extracted directory
echo " → Running installation script..." if ! cd "$maldet_dir"; then
local install_log="/tmp/maldet-install-$$.log" echo -e "${RED}✗ Cannot access directory: $maldet_dir${NC}"
if ./install.sh > "$install_log" 2>&1; then cd /tmp
install_exit=0 rm -rf "maldetect-"*
else return 1
install_exit=$? fi
fi
# Cleanup # Run installation with error capture
cd /tmp echo " → Running installation script..."
rm -rf "maldetect-"* local install_log="/tmp/maldet-install-$$.log"
if ./install.sh > "$install_log" 2>&1; then
# Check if installation succeeded install_exit=0
if is_maldet_installed; then
echo -e "${GREEN}✓ Maldet installed${NC}"
rm -f "$install_log"
# Update malware signatures immediately
echo " → Updating malware signatures..."
if maldet -u 2>&1 | grep -qE "update completed|signatures"; then
echo -e " ${GREEN}${NC} Signatures updated"
else else
echo -e " ${YELLOW}${NC} Signature update status unclear (continuing with current definitions)" install_exit=$?
fi 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..."
if maldet -u 2>&1 | grep -qE "update completed|signatures"; then
echo -e " ${GREEN}${NC} Signatures updated"
else
echo -e " ${YELLOW}${NC} Signature update status unclear (continuing with current definitions)"
fi
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
fi
return 0
else else
echo -e "${RED}Maldet installation failed${NC}" echo -e "${RED}Download failed - maldetect-current.tar.gz not found${NC}"
return 0
# 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 fi
else ) || true
echo -e "${RED}✗ Download failed - maldetect-current.tar.gz not found${NC}"
return 1
fi
else else
echo -e "${GREEN}✓ Maldet already installed${NC}" echo -e "${GREEN}✓ Maldet already installed${NC}"
fi fi