#!/usr/bin/env bash # Persistent watcher: every 5 min, finds acclient PIDs that have v3b applied # but NOT v5, applies v5 to them. Skips any PID whose window title contains "Jerry". # Emits one line per applied PID (event-style for Monitor). set -u PY="C:/Users/acbot/AppData/Local/Programs/Python/Python312/python.exe" cd /c/Users/acbot/leakhunt while true; do # Get all acclient PIDs + window titles via PowerShell pid_titles=$(powershell.exe -NoProfile -Command \ "Get-Process acclient -EA SilentlyContinue | ForEach-Object { \"\$(\$_.Id)|\$(\$_.MainWindowTitle)\" }" \ 2>/dev/null | tr -d '\r') while IFS='|' read -r pid title; do [ -z "$pid" ] && continue # Skip Jerry (control) if echo "$title" | grep -qi "Jerry"; then continue; fi # Check patch state — only proceed if v3b is applied AND v5 is not state=$("$PY" tools/check_patch_state.py "$pid" 2>/dev/null \ | awk -v p="$pid" '$1==p {print $2,$3,$5,$6}') [ -z "$state" ] && continue read v3b1 v3b2 v5rs v5rt <<<"$state" # v3b must be P/P, v5-RS must be "." (no thunk yet) if [ "$v3b1" = "P" ] && [ "$v3b2" = "P" ] && [ "$v5rs" = "." ]; then result=$("$PY" tools/patch_purge_v5_test.py "$pid" 2>&1) if echo "$result" | grep -q "OK"; then echo "AUTO-V5 PID=$pid title=\"$title\" applied $(date +%H:%M:%S)" else echo "AUTO-V5-FAIL PID=$pid title=\"$title\" output: $(echo "$result" | tail -2 | tr '\n' ' ')" fi fi done <<< "$pid_titles" sleep 300 done