uninstall.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. # Revert every change made by install.sh, restoring the *.orig backups.
  3. set -euo pipefail
  4. GAME_ROOT="${1:?usage: ./uninstall.sh <game-root-dir>}"
  5. D="$GAME_ROOT/data"
  6. APPID=2326780
  7. restore() { # <file>
  8. if [ -f "$1.orig" ]; then
  9. mv -f "$1.orig" "$1"; echo "restored $(basename "$1")"
  10. else
  11. echo "no backup for $(basename "$1") (skipped)"
  12. fi
  13. }
  14. # kill only this prefix's wineserver, matched via WINEPREFIX in its
  15. # environment; a blanket pkill would lose unflushed registry changes in
  16. # unrelated Wine prefixes
  17. kill_prefix_wineserver() { # <pfx-dir>
  18. local pfx pid env_pfx
  19. pfx="$(cd "$1" 2>/dev/null && pwd)" || return 0
  20. for pid in $(pgrep -x wineserver 2>/dev/null || true); do
  21. env_pfx="$(tr '\0' '\n' < "/proc/$pid/environ" 2>/dev/null \
  22. | sed -n 's/^WINEPREFIX=//p' | head -1 || true)"
  23. if [ -n "$env_pfx" ] && [ "${env_pfx%/}" = "$pfx" ]; then
  24. kill -9 "$pid" 2>/dev/null || true
  25. fi
  26. done
  27. }
  28. restore "$D/kmyCore.dll"
  29. restore "$D/bakinplayer.exe"
  30. restore "$D/lib/sysresource/shader/include/v2_vpcommon.cgh"
  31. # fix 5 added a single registry value, so remove just that line; restoring a
  32. # whole user.reg backup would wipe every registry change made since install
  33. PFX="$GAME_ROOT/../../compatdata/$APPID/pfx"
  34. REG="$PFX/user.reg"
  35. if [ -f "$REG" ] && grep -qaxF '"UseTakeFocus"="N"' "$REG"; then
  36. kill_prefix_wineserver "$PFX" # so wineserver can't flush over our edit
  37. tmp="$(mktemp)"
  38. grep -vaxF '"UseTakeFocus"="N"' "$REG" > "$tmp"
  39. cp "$tmp" "$REG"; rm -f "$tmp"
  40. echo "removed UseTakeFocus=N from user.reg (.bak-* backups kept as fallback)"
  41. else
  42. echo "UseTakeFocus=N not present in user.reg (nothing to revert)"
  43. fi
  44. echo "Done. Also clear the game's Steam Launch Options if you set them."