Compare commits

..

1 Commits

Author SHA1 Message Date
Jenkins Server
ce83e4bbab Recommit for updates in build 4 2026-09-22 12:46:10 +02:00

View File

@@ -1,26 +1,23 @@
#!/bin/bash
set -euo pipefail
# Set paths
SCAN_DIR="<%= @cv_scan_dir %>"
LOG_FILE="<%= @cv_logfile %>"
TMP_ALERT="<%= @cv_alert_file %>"
EMAIL="<%= @cv_alert_email %>"
# Ensure the log directory exists
mkdir -p "$(dirname "$LOG_FILE")"
# Run clamscan
clamscan -r --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null
# 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"
# Check if infections were found
if grep -q "Infected files: [^0]" "$LOG_FILE"; then
echo "ClamAV has found infected files on $(hostname)!" > "$TMP_ALERT"
echo "" >> "$TMP_ALERT"
grep "FOUND" "$LOG_FILE" >> "$TMP_ALERT"
# Send the alert email
mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT"
fi
# Clean up
rm -f "$TMP_ALERT"