152 lines
4.0 KiB
Bash
Executable File
152 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Quick Fix Script for ClamAV Installation Issues
|
|
# Run this if the main setup script failed due to clamav-unofficial-sigs
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
info() {
|
|
echo -e "${BLUE}INFO: $1${NC}"
|
|
}
|
|
|
|
success() {
|
|
echo -e "${GREEN}SUCCESS: $1${NC}"
|
|
}
|
|
|
|
warning() {
|
|
echo -e "${YELLOW}WARNING: $1${NC}"
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}ERROR: $1${NC}" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
error "This script must be run as root"
|
|
fi
|
|
|
|
info "Fixing ClamAV installation issues..."
|
|
|
|
# Update package lists
|
|
apt update
|
|
|
|
# Install core ClamAV packages
|
|
info "Installing ClamAV packages..."
|
|
apt install -y \
|
|
clamav \
|
|
clamav-daemon \
|
|
clamav-freshclam
|
|
|
|
# Try alternative methods for unofficial signatures
|
|
info "Setting up ClamAV unofficial signatures..."
|
|
|
|
# Method 1: Try installing from different repository
|
|
if apt-cache show clamav-unofficial-sigs >/dev/null 2>&1; then
|
|
apt install -y clamav-unofficial-sigs
|
|
success "Installed clamav-unofficial-sigs from repository"
|
|
else
|
|
warning "clamav-unofficial-sigs not available in repositories"
|
|
|
|
# Method 2: Manual installation of unofficial signatures script
|
|
info "Installing unofficial signatures manually..."
|
|
|
|
# Download and install the script manually
|
|
cd /tmp
|
|
if wget -q https://github.com/extremeshok/clamav-unofficial-sigs/archive/master.zip; then
|
|
apt install -y unzip
|
|
unzip -q master.zip
|
|
cd clamav-unofficial-sigs-master
|
|
|
|
# Install the script
|
|
cp clamav-unofficial-sigs.sh /usr/local/bin/
|
|
chmod +x /usr/local/bin/clamav-unofficial-sigs.sh
|
|
|
|
# Create configuration
|
|
mkdir -p /etc/clamav-unofficial-sigs
|
|
cp config/user.conf /etc/clamav-unofficial-sigs/
|
|
|
|
# Set up cron job for updates
|
|
echo "0 */6 * * * /usr/local/bin/clamav-unofficial-sigs.sh" | crontab -
|
|
|
|
success "Manually installed clamav-unofficial-sigs"
|
|
else
|
|
warning "Could not download unofficial signatures script - continuing without it"
|
|
fi
|
|
fi
|
|
|
|
# Ensure ClamAV is properly configured
|
|
info "Configuring ClamAV..."
|
|
|
|
# Update virus definitions
|
|
info "Updating virus definitions..."
|
|
if freshclam; then
|
|
success "Virus definitions updated"
|
|
else
|
|
warning "Failed to update virus definitions - this may be temporary"
|
|
fi
|
|
|
|
# Start and enable ClamAV services
|
|
info "Starting ClamAV services..."
|
|
systemctl enable clamav-daemon
|
|
systemctl enable clamav-freshclam
|
|
|
|
# Stop freshclam service temporarily to avoid conflicts
|
|
systemctl stop clamav-freshclam 2>/dev/null || true
|
|
|
|
# Start daemon
|
|
if systemctl start clamav-daemon; then
|
|
success "ClamAV daemon started"
|
|
else
|
|
warning "ClamAV daemon failed to start - checking configuration..."
|
|
|
|
# Check for common issues
|
|
if [[ ! -f "/var/lib/clamav/main.cvd" ]]; then
|
|
info "Missing virus database, updating..."
|
|
freshclam
|
|
systemctl start clamav-daemon
|
|
fi
|
|
fi
|
|
|
|
# Restart freshclam service
|
|
systemctl start clamav-freshclam
|
|
|
|
# Verify installation
|
|
info "Verifying ClamAV installation..."
|
|
if systemctl is-active --quiet clamav-daemon; then
|
|
success "ClamAV daemon is running"
|
|
else
|
|
error "ClamAV daemon is not running"
|
|
fi
|
|
|
|
if systemctl is-active --quiet clamav-freshclam; then
|
|
success "ClamAV freshclam is running"
|
|
else
|
|
warning "ClamAV freshclam is not running (this may be normal)"
|
|
fi
|
|
|
|
# Test ClamAV
|
|
info "Testing ClamAV..."
|
|
if echo "X5O!P%@AP[4\PZX54(P^)7CC)7}\$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!\$H+H*" | clamdscan --stream 2>/dev/null | grep -q "FOUND"; then
|
|
success "ClamAV is working correctly"
|
|
else
|
|
warning "ClamAV test inconclusive - may still be starting up"
|
|
fi
|
|
|
|
success "ClamAV setup completed!"
|
|
echo
|
|
echo "You can now continue with the main email server setup script."
|
|
echo "The absence of clamav-unofficial-sigs will not affect core functionality."
|
|
echo
|
|
echo "To check ClamAV status later:"
|
|
echo " systemctl status clamav-daemon"
|
|
echo " systemctl status clamav-freshclam"
|