Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # V2 of my Game Installer Script Based on the original JC141 Script as it appeared in BG3.
- # Assumes multiple games are stored in conveniently-named subdirectories with a 'setup.exe' in them, and
- # takes a folder name on the command line, creates all the applicable directories and a WINE prefix for
- # it, downloads and installs, the newest version of VULKAN, starts the setup.exe located in the folder
- # provided on the command line, and writes a version of the installer script out as the game start script.
- #
- # Changes from v1:
- # - Rather than create individually named bottles each time it gets run as V1 did, this version installs
- # the game to a named folder in a pre-set prefix to conserve disk space, which I plan to make optional in V3.
- # - Replaces whitespace in the command line with underscores to make a custom named starting script for the game
- # which replaces the original version of starting script, reflecting changes made to this installer.
- # - Copies and runs all MSVCPP redistributables from the folder REDIST, located in the script's starting directory.
- # - Removed WAN blocking
- # - Removed dwarfs checking
- # - Added some extra directory and CLI parameter verification checks
- # - Added some notes
- # - Added a loop to copy and install MSVC 2022 redistributables
- # - Made installer script partially interactive
- # TO DO in v3:
- # - Add colour to prompts and output (probably)
- # Basic checks
- cd "$(dirname "$(readlink -f "$0")")" || exit; [ "$EUID" = "0" ] && echo "For the love of God! Please don't run this as root!" && exit; [ "$1" = "" ] && echo "Command line can't be blank - please choose a game." && exit
- if [ ! -d "$1" ]; then
- echo "Sorry... I can't find \"$1\" in this folder."
- exit 255
- elif [ ! -f "$1/setup.exe" ]; then
- echo "Sorry... \"$1\" doesn't have a \"setup.exe\" installer."
- exit 255
- fi
- # Declarations
- export G="${1// /_}"
- export GAMESRC="$PWD/$1"
- export WINEPREFIX="/home/$(whoami)/Games/jc141" #Create Wineprefix
- export GAMEDIR="$WINEPREFIX/drive_c/Games/$1"; [ ! -d "$GAMEDIR" ] && mkdir -p "$GAMEDIR" #If $GAMEDIR doesn't exist, create it
- export GSS="$WINEPREFIX/drive_c/${G}.sh" #Convert spaces to underscores, if they exist, for the launcher script
- export RSRC="$PWD/redist"
- export WINE="$(command -v wine)"
- export WINEDLLOVERRIDES="winemenubuilder.exe=d;mshtml=d;nvapi,nvapi64=n"
- export WINE_LARGE_ADDRESS_AWARE=1
- echo ""
- echo "Declarations:"
- echo ""
- echo "G=\"${1// /_}\""
- echo "GAMESRC=\"$PWD/$1\""
- echo "WINEPREFIX=\"/home/$(whoami)/Games/jc141\""
- echo "GAMEDIR=\"$WINEPREFIX/drive_c/Games"
- echo "GSS=\"$WINEPREFIX/drive_c/${G}.sh\""
- echo "RSRC=\"$PWD/redist\""
- echo "WINE=\"$(command -v wine)\""
- echo "WINEDLLOVERRIDES=\"winemenubuilder.exe=d;mshtml=d;nvapi,nvapi64=n\""
- echo ""
- echo "Variables Declared. Starting Vulkan setup."
- echo ""
- echo ""
- # external vulkan translation
- #export DXVK_ASYNC=1
- ping -c 1 github.com >/dev/null || { echo "Possibly no network. This may mean that booting will fail." ; }; VLKLOG="$WINEPREFIX/vulkan.log"; VULKAN="$PWD/vulkan"
- VLKVER="$(curl -s -m 5 https://api.github.com/repos/jc141x/vulkan/releases/latest | awk -F '["/]' '/"browser_download_url":/ {print $11}' | cut -c 1-)"
- status-vulkan() { [[ ! -f "$VLKLOG" || -z "$(awk "/^${FUNCNAME[1]}\$/ {print \$1}" "$VLKLOG" 2>/dev/null)" ]] || { echo "${FUNCNAME[1]} present" && return 1; }; }
- vulkan() { DL_URL="$(curl -s https://api.github.com/repos/jc141x/vulkan/releases/latest | awk -F '["]' '/"browser_download_url":/ {print $4}')"; VLK="$(basename "$DL_URL")"
- [ ! -f "$VLK" ] && command -v curl >/dev/null 2>&1 && curl -LO "$DL_URL" && tar -xvf "vulkan.tar.xz" || { rm "$VLK" && echo "ERROR: Failed to extract vulkan translation." && return 1; }
- rm -rf "vulkan.tar.xz" && bash "$PWD/vulkan/setup-vulkan.sh" && rm -Rf "$VULKAN"; }
- vulkan-dl() { echo "Using external vulkan translation (dxvk,vkd3d,dxvk-nvapi)." && vulkan && echo "$VLKVER" >"$VLKLOG"; }
- [[ ! -f "$VLKLOG" && -z "$(status-vulkan)" ]] && vulkan-dl;
- [[ -f "$VLKLOG" && -n "$VLKVER" && "$VLKVER" != "$(awk '{print $1}' "$VLKLOG")" ]] && { rm -f vulkan.tar.xz || true; } && vulkan-dl; export DXVK_ENABLE_NVAPI=1
- echo ""
- if [ "$2" == "skip" ]; then
- YN="y"
- else
- read -p "Skip installing MSVC redistributables? (y/n) " YN
- fi
- echo ""
- case $YN in
- [nN] ) echo "Proceeding with install.";
- cd "$RSRC";
- for i in *.exe;
- do
- echo "Installing $i into $WINEPREFIX";
- "$WINE" "$i";
- done;;
- [yY] ) echo "Skipping redistributables. Don't blame me if something breaks.";;
- * ) echo "Invalid response.";
- break;;
- esac
- echo ""
- echo "Writing Game Starter Script (GSS) for $1 to $GSS ..."
- echo ""
- #create game starter script
- cat << EOL > "$GSS"
- #!/bin/bash
- # $GSS #
- cd "\$(dirname "\$(readlink -f "\$0")")" || exit; [ "\$EUID" = "0" ] && echo "Please don't run as root!" && exit
- # wine
- export WINE="\$(command -v wine)";
- export WINEPREFIX="/home/\$(whoami)/Games/jc141"; export WINEDLLOVERRIDES="winemenubuilder.exe=d;mshtml=d;nvapi,nvapi64=n"
- export WINE_LARGE_ADDRESS_AWARE=1;
- export GAMEDIR="\$WINEPREFIX/drive_c/Games/$1"
- # external vulkan translation
- #export DXVK_ASYNC=1
- ping -c 1 github.com >/dev/null || { echo "Possibly no network. This may mean that booting will fail." ; }; VLKLOG="\$WINEPREFIX/vulkan.log"; VULKAN="\$PWD/vulkan"
- VLKVER="\$(curl -s -m 5 https://api.github.com/repos/jc141x/vulkan/releases/latest | awk -F '["/]' '/"browser_download_url":/ {print \$11}' | cut -c 1-)"
- status-vulkan() { [[ ! -f "\$VLKLOG" || -z "\$(awk "/^\${FUNCNAME[1]}\$/ {print \$1}" "\$VLKLOG" 2>/dev/null)" ]] || { echo "\${FUNCNAME[1]} present" && return 1; }; }
- vulkan() { DL_URL="\$(curl -s https://api.github.com/repos/jc141x/vulkan/releases/latest | awk -F '["]' '/"browser_download_url":/ {print \$4}')"; VLK="\$(basename "\$DL_URL")"
- [ ! -f "\$VLK" ] && command -v curl >/dev/null 2>&1 && curl -LO "\$DL_URL" && tar -xvf "vulkan.tar.xz" || { rm "\$VLK" && echo "ERROR: Failed to extract vulkan translation." && return 1; }
- rm -rf "vulkan.tar.xz" && bash "\$PWD/vulkan/setup-vulkan.sh" && rm -Rf "\$VULKAN"; }
- vulkan-dl() { echo "Using external vulkan translation (dxvk,vkd3d,dxvk-nvapi)." && vulkan && echo "\$VLKVER" >"\$VLKLOG"; }
- [[ ! -f "\$VLKLOG" && -z "\$(status-vulkan)" ]] && vulkan-dl;
- [[ -f "\$VLKLOG" && -n "\$VLKVER" && "\$VLKVER" != "\$(awk '{print \$1}' "\$VLKLOG")" ]] && { rm -f vulkan.tar.xz || true; } && vulkan-dl
- # start
- export DXVK_ENABLE_NVAPI=1
- cd "\$GAMEDIR"
- "\$WINE" "setup.exe" "\$@"
- EOL
- chmod a+x "$GSS"
- echo ""
- cat $GSS
- echo ""
- echo "\"$GSS\" written and made executable."
- echo ""
- # start installer
- echo ""
- echo "Starting \"$1\" installer..."
- echo ""
- cd "$GAMESRC"; "$WINE" "setup.exe" "$@"
- echo ""
- echo "Path of the $1 wineprefix is: $WINEPREFIX"
- echo ""
- echo "Be sure to change the name of the game executable in \"$GSS\" from \"setup.exe\"."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement