Fix: Handle different extracted directory names for Maldet installation

Issue: Installation failed because script expected 'maldetect-*' directory but GitHub releases extract to 'rfxn-linux-malware-detect-*'.

Root cause: Hardcoded glob pattern 'cd maldetect-*' didn't match actual extracted directory name.

Solution:
- Use find to locate extracted directory (matches both *malware* and *maldet*)
- Check if install.sh exists before attempting to run it
- Better error messages showing what went wrong
- Also clean up rfxn-linux-malware-detect-* directories
- Proper error reporting if directory not found

Now supports multiple Maldet archive formats/naming schemes.
This commit is contained in:
Developer
2026-04-21 20:14:05 -04:00
parent d38ebdc464
commit df3888b3c2
+13 -2
View File
@@ -425,7 +425,12 @@ install_maldet_only() {
echo " Extracting archive..." echo " Extracting archive..."
if tar xzf "$temp_file" 2>/dev/null; then if tar xzf "$temp_file" 2>/dev/null; then
echo " Running installer..." echo " Running installer..."
if cd maldetect-* 2>/dev/null && bash install.sh > /tmp/maldet-install.log 2>&1; then # Find the extracted directory (could be maldetect-* or rfxn-linux-malware-detect-*)
local install_dir
install_dir=$(find . -maxdepth 1 -type d \( -name "*malware*" -o -name "*maldet*" \) 2>/dev/null | head -1)
if [ -n "$install_dir" ] && [ -f "$install_dir/install.sh" ]; then
if cd "$install_dir" 2>/dev/null && bash install.sh > /tmp/maldet-install.log 2>&1; then
echo -e " ${GREEN}✓ Maldet installed successfully${NC}" echo -e " ${GREEN}✓ Maldet installed successfully${NC}"
# Update signatures in background # Update signatures in background
@@ -438,8 +443,14 @@ install_maldet_only() {
else else
echo -e " ${RED}✗ Installation failed. Check /tmp/maldet-install.log${NC}" echo -e " ${RED}✗ Installation failed. Check /tmp/maldet-install.log${NC}"
fi fi
else
echo -e " ${RED}✗ Could not find install.sh in extracted directory${NC}"
if [ -z "$install_dir" ]; then
echo " (Directory not found matching *malware* or *maldet*)"
fi
fi
cd /tmp cd /tmp
rm -rf maldetect-* maldetect-latest.tar.gz 2>/dev/null || true rm -rf maldetect-* rfxn-linux-malware-detect-* maldetect-latest.tar.gz 2>/dev/null || true
else else
echo -e " ${RED}✗ Failed to extract archive${NC}" echo -e " ${RED}✗ Failed to extract archive${NC}"
rm -f "$temp_file" rm -f "$temp_file"