Dotfiles/setup/modules/optional-Modules/apps/anti-malware.sh

25 lines
677 B
Bash

#!/bin/bash
set -euo pipefail
sudo pacman -S --noconfirm --needed \
clamav clamtk rkhunter
yay -S --aur --noconfirm --needed chkrootkit
# initialise ClamAV database (first run)
if [[ ! -f /var/lib/clamav/main.cvd ]] && [[ ! -f /var/lib/clamav/main.cld ]]; then
echo "Running initial freshclam..."
sudo freshclam
fi
# cron job: update virus definitions twice a day
CRON_FILE=/etc/cron.d/freshclam
if [[ ! -f "$CRON_FILE" ]]; then
echo "Installing freshclam cron job..."
sudo tee "$CRON_FILE" > /dev/null <<'EOF'
# Update ClamAV virus definitions twice a day
0 */12 * * * root /usr/bin/freshclam --quiet 2>/dev/null
EOF
sudo chmod 644 "$CRON_FILE"
fi