Update docker/clam/docker-entrypoint.sh
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/cron/woodpecker Pipeline was successful Details

This commit is contained in:
colin 2024-10-29 22:35:34 -04:00
parent 0d7d49738f
commit bd6953084a
1 changed files with 12 additions and 28 deletions

View File

@ -11,37 +11,21 @@ create_temp_log() {
scan() {
echo "Running ClamAV scan..."
SCAN_PRIORITY=${SCAN_PRIORITY:-low}
local retry_count=0
local max_retries=5
if [ "$SCAN_PRIORITY" = "low" ]; then
echo "Running scan in low priority mode."
while ! nice -n 19 clamscan -r /scan --log=/var/log/clamav/clamav.log; do
retry_count=$((retry_count + 1))
if [ "$retry_count" -ge "$max_retries" ]; then
echo "Max retries reached. Sending failure report to GlitchTip..."
create_temp_log "/var/log/clamav/clamav.log"
go-glitch report --dsn "$GLITCHTIP_DSN" "$temp_log_file" || echo "Failed to report scan failure to GlitchTip"
return
fi
echo "Scan failed. Retrying... ($retry_count/$max_retries)"
sleep 5
done
else
echo "Running scan in full power mode."
while ! clamscan -r /scan --log=/var/log/clamav/clamav.log; do
retry_count=$((retry_count + 1))
if [ "$retry_count" -ge "$max_retries" ]; then
echo "Max retries reached. Sending failure report to GlitchTip..."
create_temp_log "/var/log/clamav/clamav.log"
go-glitch report --dsn "$GLITCHTIP_DSN" "$temp_log_file" || echo "Failed to report scan failure to GlitchTip"
return
fi
echo "Scan failed. Retrying... ($retry_count/$max_retries)"
sleep 5
done
fi
echo "Running scan in optimized mode to reduce resource usage."
while ! clamscan -r --max-scansize=100M --max-filesize=50M --max-recursion=5 --log=/var/log/clamav/clamav.log /scan; do
retry_count=$((retry_count + 1))
if [ "$retry_count" -ge "$max_retries" ]; then
echo "Max retries reached. Sending failure report to GlitchTip..."
create_temp_log "/var/log/clamav/clamav.log"
go-glitch report --dsn "$GLITCHTIP_DSN" "$temp_log_file" || echo "Failed to report scan failure to GlitchTip"
return
fi
echo "Scan failed. Retrying... ($retry_count/$max_retries)"
sleep 5
done
}
report() {