Fix Maldet directory detection after extraction

Problem:
- cd maldetect-* was failing because glob expansion doesn't work
  reliably in this context
- Error: "Cannot find extracted directory"

Solution:
- Use find command to locate extracted directory explicitly
- Store directory path in variable before cd
- Add diagnostic output showing available directories on failure
- More robust error handling with explicit directory checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-01-02 21:29:37 -05:00
parent 2c67d48e7c
commit a7f537ef80
+13 -2
View File
@@ -235,9 +235,20 @@ install_all_scanners() {
return 1
fi
# Change to extracted directory
if ! cd maldetect-* 2>/dev/null; then
# Find the extracted directory
local maldet_dir=$(find /tmp -maxdepth 1 -type d -name "maldetect-*" 2>/dev/null | head -1)
if [ -z "$maldet_dir" ]; then
echo -e "${RED}✗ Cannot find extracted directory${NC}"
echo " Available directories in /tmp:"
ls -la /tmp | grep maldetect | sed 's/^/ /'
cd /tmp
rm -rf "maldetect-"*
return 1
fi
# Change to extracted directory
if ! cd "$maldet_dir"; then
echo -e "${RED}✗ Cannot access directory: $maldet_dir${NC}"
cd /tmp
rm -rf "maldetect-"*
return 1