Files
VIctory-NVIDIA-2/scripts/get-mfg-unlocker.sh

71 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Linux stand-in for scripts/get-mfg-unlocker.ps1, which needs Windows PowerShell. Fetches MFG
# Unlocker (github.com/dashdogy/MFG-Unlocker, someone else's MIT-licensed mod, about 5 MB) into a
# Wine/Proton prefix's %LOCALAPPDATA%\victory\mfg-unlocker, where victory.exe looks for it with
# F1's MFG UNLOCKER on. It lets DLSS Frame Generation run on GeForce RTX 20 and 30 cards, which
# NVIDIA does not support; it is not part of this repository. Release v1.7.2 is pinned: the zip and
# the DLL in it are checked against the same SHA-256 values as get-mfg-unlocker.ps1, and nothing
# else is kept but its licence and notices.
#
# get-mfg-unlocker.sh <wine prefix>
#
# Needs curl and python3. Nothing is run from the download.
set -euo pipefail
prefix=${1:?usage: get-mfg-unlocker.sh <wine prefix>}
[[ -d $prefix/drive_c ]] || { echo "$prefix has no drive_c: start victory.exe in it once, or make it with wineboot" >&2; exit 2; }
version=1.7.2
package=e002d624e3e7ba5cedab7211043c096fe8f555c30ff43500235a0686c7893f22
module=a9b1c01727fa72763bef8f604e44ec165ce1c98272de00719572b766a11cf28f
url="https://github.com/dashdogy/MFG-Unlocker/releases/download/v$version/MFGUnlocker-v$version.zip"
user=steamuser
[[ -d $prefix/drive_c/users/$user ]] || user=$(id -un)
dir=$prefix/drive_c/users/$user/AppData/Local/victory/mfg-unlocker
target=$dir/MFGUnlocker.dll
if [[ -f $target ]] && [[ $(sha256sum "$target" | cut -d' ' -f1) == "$module" ]]; then
echo "MFG Unlocker $version is already in $dir"; exit 0
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
echo "MFG Unlocker $version (someone else's mod), from github.com/dashdogy/MFG-Unlocker (about 5 MB):"
curl --fail --location --proto '=https' --tlsv1.2 --progress-bar --output "$work/mfg.zip" "$url"
hash=$(sha256sum "$work/mfg.zip" | cut -d' ' -f1)
[[ $hash == "$package" ]] || { echo "the zip is not the v$version release (SHA-256 $hash); not kept" >&2; exit 1; }
mkdir -p "$dir"
# Only MFGUnlocker.dll and the licence and notice files, each under its own base name.
python3 -I - "$work/mfg.zip" "$work" "$dir" <<'PY'
import os, sys, zipfile
archive, work, dest = sys.argv[1:]
docs = {"LICENSE", "LICENSE.txt", "NOTICE.md", "NOTICE.txt", "README.md", "README.txt"}
dll = None
with zipfile.ZipFile(archive) as z:
for info in z.infolist():
base = os.path.basename(info.filename)
if info.is_dir() or not base:
continue
if base == "MFGUnlocker.dll" and dll is None:
out = os.path.join(work, "MFGUnlocker.dll")
dll = out
elif base in docs:
out = os.path.join(dest, base)
else:
continue
with z.open(info) as src, open(out, "wb") as dst:
dst.write(src.read())
if dll is None:
sys.exit("the zip has no MFGUnlocker.dll")
PY
hash=$(sha256sum "$work/MFGUnlocker.dll" | cut -d' ' -f1)
[[ $hash == "$module" ]] || { echo "MFGUnlocker.dll is not the v$version file (SHA-256 $hash); not kept" >&2; exit 1; }
mv "$work/MFGUnlocker.dll" "$target"
echo " MFGUnlocker.dll $(( $(stat -c %s "$target") / 1048576 )) MB, v$version, checked against the published SHA-256"
if compgen -G "$dir/LICENSE*" >/dev/null || compgen -G "$dir/NOTICE*" >/dev/null; then
echo " in $dir (its licence and notices beside it)"
else
echo " in $dir (the zip carries no licence file: MIT, github.com/dashdogy/MFG-Unlocker/blob/main/LICENSE)"
fi
echo "Turn it on in the game: F1, MFG UNLOCKER, ON (or victory play --set VICTORY_MFG_UNLOCKER=1)."