Files

27 lines
721 B
Plaintext
Raw Permalink Normal View History

2025-06-08 15:33:03 +02:00
#!/bin/bash
2026-09-22 12:52:19 +02:00
set -euo pipefail
2025-06-08 15:33:03 +02:00
SCAN_DIR="<%= @cv_scan_dir %>"
LOG_FILE="<%= @cv_logfile %>"
TMP_ALERT="<%= @cv_alert_file %>"
EMAIL="<%= @cv_alert_email %>"
2026-09-22 12:52:19 +02:00
# Ensure the log directory exists
mkdir -p "$(dirname "$LOG_FILE")"
2025-06-08 15:33:03 +02:00
2026-09-22 12:52:19 +02:00
# Preferred: clamdscan with multiscan + fdpass
clamdscan --multiscan --fdpass --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null || true
# Check for infections (same logic as before)
if grep -q "Infected files: [^0]" "$LOG_FILE" 2>/dev/null; then
{
echo "ClamAV has found infected files on $(hostname)!"
echo ""
grep "FOUND" "$LOG_FILE" || true
} > "$TMP_ALERT"
2025-06-08 15:33:03 +02:00
mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT"
fi
2026-09-22 12:57:15 +02:00
rm -f "$TMP_ALERT"