#!/bin/bash set -m echo "Starting ClamAV services..." # Try to download database if missing # if [ ! "$(ls -A /var/lib/clamav 2>/dev/null)" ]; then # echo "Downloading ClamAV database (this may take a while)..." # # Simple freshclam run without complex config # if freshclam --datadir=/var/lib/clamav --quiet; then # echo "✓ Database downloaded successfully" # else # echo "⚠ Database download failed - creating minimal setup" # # Create a dummy file so clamd doesn't immediately fail # touch /var/lib/clamav/.dummy # fi # fi # Start freshclam daemon for automatic updates echo "Starting freshclam daemon for automatic updates..." # sg clamav -c "freshclam -d" & # Added --daemon-notify to freshclam - This notifies clamd when the database updates freshclam -d --daemon-notify=/etc/clamav/clamd.conf & #freshclam -d & # /etc/init.d/clamav-freshclam start & # Start clamd in background # Start clamd in foreground (so dumb-init can supervise it) # /etc/init.d/clamav-daemon start & # Give freshclam a moment to start sleep 2 # Start clamd daemon in background using sg echo "Starting ClamAV daemon..." # sg clamav -c "clamd" & # Use sg to run clamd with proper group permissions # sg clamav -c "clamd" & # clamd --config-file=/etc/clamav/clamd.conf & clamd & # Give services time to start echo "Waiting for services to initialize..." sleep 8 # simple check if pgrep clamd > /dev/null; then echo "✓ ClamAV daemon is running" else echo "⚠ ClamAV daemon status uncertain, but continuing..." fi # Check if freshclam daemon is running if pgrep freshclam > /dev/null; then echo "✓ Freshclam daemon is running" else echo "⚠ Freshclam daemon status uncertain, but continuing..." fi # # Optional: Test socket connectivity # if [ -S /var/run/clamav/clamd.socket ]; then # echo "✓ ClamAV socket exists" # else # echo "⚠ WARNING: ClamAV socket not found - services may still be starting" # fi # # change back to CMD of dockerfile echo "✓ ClamAV setup complete" echo "Starting main application..." # exec dumb-init -- "$@" exec "$@"