#!/usr/bin/env bash
# Остановить JA3 / Wine (CrossOver bottle JA3-GOG) перед перезапуском.
set -euo pipefail
GOG_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=gog-process.sh
source "${GOG_DIR}/gog-process.sh"

bash "${GOG_DIR}/emergency-stop.sh" 2>/dev/null || gog_kill_all
pkill -f 'JA3\.exe' 2>/dev/null || true
pkill -f 'wineserver.*JA3-GOG' 2>/dev/null || true

CX="/Applications/CrossOver.app/Contents/SharedSupport/CrossOver"
if [[ -x "${CX}/bin/wine" ]]; then
  "${CX}/bin/wine" --bottle JA3-GOG wineboot --kill 2>/dev/null || true
fi
sleep 2
pgrep -fl 'JA3\.exe|wineserver' 2>/dev/null | head -5 || echo "OK: процессы JA3/Wine остановлены"
