Fix ImunifyAV completion detection - use COMPLETED field not STATUS
The previous fix was close but used the wrong field to detect completion. Issue: ImunifyAV uses "stopped" as the SCAN_STATUS even for successful scans. The COMPLETED field (field 1) contains the completion timestamp. Changed detection from: - if SCAN_STATUS in (completed|stopped|failed) ← Wrong, always "stopped" To: - if COMPLETED field has timestamp > 0 ← Correct indicator This is the proper way to detect when an ImunifyAV scan finishes. Now 99% confident this will work correctly.
This commit is contained in:
@@ -848,25 +848,18 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
||||
scan_info=$(imunify-antivirus malware on-demand list 2>/dev/null | tail -n +2 | head -1)
|
||||
|
||||
if [ -n "$scan_info" ]; then
|
||||
current_files=$(echo "$scan_info" | awk '{print $11}')
|
||||
current_status=$(echo "$scan_info" | awk '{print $7}') # Field 7 is SCAN_STATUS
|
||||
completed_time=$(echo "$scan_info" | awk '{print $1}') # Field 1 is COMPLETED timestamp
|
||||
created_time=$(echo "$scan_info" | awk '{print $2}') # Field 2 is CREATED
|
||||
current_files=$(echo "$scan_info" | awk '{print $11}') # Field 11 is TOTAL
|
||||
current_status=$(echo "$scan_info" | awk '{print $7}') # Field 7 is SCAN_STATUS
|
||||
|
||||
# Check if this is our scan (created after scan start)
|
||||
# Check if this is our scan (created after we started)
|
||||
if [ "$created_time" -ge "$SCAN_START" ]; then
|
||||
# Check status
|
||||
if [[ "$current_status" =~ ^(completed|stopped|failed)$ ]]; then
|
||||
# Check if scan is complete (COMPLETED field has timestamp)
|
||||
if [ -n "$completed_time" ] && [ "$completed_time" != "COMPLETED" ] && [ "$completed_time" -gt 0 ]; then
|
||||
scan_running=false
|
||||
echo "" # New line after progress
|
||||
|
||||
if [ "$current_status" = "failed" ]; then
|
||||
log_message "ERROR: ImunifyAV scan failed for $path"
|
||||
echo " ✗ Scan failed for $path"
|
||||
continue 2
|
||||
elif [ "$current_status" = "stopped" ]; then
|
||||
log_message "WARNING: ImunifyAV scan was stopped for $path"
|
||||
echo " ⚠️ Scan was stopped (may be incomplete)"
|
||||
fi
|
||||
log_message "ImunifyAV scan finished for $path (status: $current_status)"
|
||||
break
|
||||
fi
|
||||
|
||||
@@ -874,8 +867,8 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
||||
if [[ "$current_files" =~ ^[0-9]+$ ]]; then
|
||||
if [ "$current_files" != "$last_count" ]; then
|
||||
elapsed=$(($(date +%s) - SCAN_START))
|
||||
printf "\r Files scanned: %s | Elapsed: %s | Status: %s " \
|
||||
"$current_files" "$(format_time $elapsed)" "$current_status"
|
||||
printf "\r Files scanned: %s | Elapsed: %s " \
|
||||
"$current_files" "$(format_time $elapsed)"
|
||||
last_count=$current_files
|
||||
timeout_counter=0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user