brick-hill-linux/brick-hill-installer.sh

160 lines
4.4 KiB
Bash
Executable file

#!/bin/bash
mkdir -p $HOME/.local/share/brick-hill-prefix
WINEPREFIXX=$HOME/.local/share/brick-hill-prefix
# To change what WINE that is used, specify the path. An example would be wine-tkg/bin/wine
WINEBIN=Default
# Variables for known Polygon install locations
BRICKHILLPATH=$WINEPREFIXX/drive_c/users/$USER/AppData/Roaming/Brick\ Hill
if [[ ($WINEBIN == Default) ]]; then
WINEBIN=$(which wine)
else
echo "Warning: using custom wine binary"
fi
#Dependencies
fedora_install () {
sudo dnf install wine winetricks
}
ubuntu_install () {
sudo apt install wine winetricks
}
debian_install () {
sudo apt install wine-development winetricks
}
arch_install () {
sudo pacman -S --needed wine winetricks
}
alpine_install () {
doas apk add wine winetricks
}
check_dependencies() {
if grep -q "Fedora" /etc/*-release; then
echo "Detected Fedora!"
fedora_install
elif grep -qE "Ubuntu|LinuxMint|Pop" /etc/*-release; then
echo "Detected Ubuntu or derivative!"
ubuntu_install
elif grep -q "Debian" /etc/*-release; then
echo "Detected Debian!"
debian_install
elif grep -qE "Arch Linux|SteamOS" /etc/*-release; then
echo "Detected Arch Linux or derivative!"
arch_install
elif grep -q "Alpine Linux" /etc/*-release; then
echo "Detected Alpine Linux!"
alpine_install
else
echo "You're on an unsupported distro. Please manually install the required dependencies from the README.md or make a pull request adding support for your distro."
exit
fi
}
download_game_base () {
if [ $WINEPREFIXX ]; then
echo "Prefix already exists, removing"
rm -rf $WINEPREFIXX
mkdir -p $WINEPREFIXX
else
echo "No prefix exists, creating one"
mkdir -p $WINEPREFIXX
fi
}
download_game () {
rm -f "BrickHillSetup.exe"
wget "https://brkcdn.com/downloads/BrickHillSetup.exe"
env WINEPREFIX=$WINEPREFIXX $WINEBIN "BrickHillSetup.exe"
echo "Brick Hill Downloaded and installed!"
}
#Creates .desktop files
desktop_file () {
DESKTOPFILE=$HOME/.local/share/applications/BrickHillURL.desktop
MIMETYPE=x-scheme-handler/brickhill.legacy
echo "[Desktop Entry]" > $DESKTOPFILE
echo "Version=1.0" >> $DESKTOPFILE
echo "Type=Application" >> $DESKTOPFILE
echo "Name=Brick Hill URL" >> $DESKTOPFILE
echo "Comment=Play Brick Hill games!" >> $DESKTOPFILE
echo "Exec=env WINEPREFIX=$WINEPREFIXX $WINEBIN '$BRICKHILLPATH/Player.exe' %u" >> $DESKTOPFILE
echo "Categories=Game;" >> $DESKTOPFILE
echo "MimeType=$MIMETYPE;" >> $DESKTOPFILE
echo "Created Brick Hill desktop file!"
}
url_handler_base () {
#Add entries for URL handlers
MIMEAPPS=$HOME/.local/share/applications/mimeapps.list
MIMEAPPSBAK=$HOME/.local/share/applications/mimeapps.list.bak
if [ -f "$MIMEAPPS" ]; then
echo "$MIMEAPPS already exists"
echo "Making a backup as mimeapps.list.bak"
echo "In case the script messes it up"
cp $MIMEAPPS $MIMEAPPSBAK
else
echo "[Default Applications]" > $MIMEAPPS
fi
}
url_handler () {
MIMEENTRY="$MIMETYPE=$(basename "$DESKTOPFILE")"
if grep -Fxq "$MIMEENTRY" "$MIMEAPPS"
then
echo "URL handler for 10 is already created! Skipping..."
else
echo $MIMEENTRY >> $MIMEAPPS
echo "Created URL handler for Brick Hill!"
fi
}
install_winetricks_dependencies () {
env WINEPREFIX=$WINEPREFIXX winetricks --unattended dotnet40 gdiplus
}
resync_databases () {
update-desktop-database "$HOME/.local/share/applications"
update-mime-database "$HOME/.local/share/mime"
echo "Synced desktop and mime databases"
}
kill_processes () {
env WINEPREFIX=$WINEPREFIXX "$WINEBIN"server -k
}
run_updater () {
env WINEPREFIX=$WINEPREFIXX $WINEBIN $WINEPREFIXX/drive_c/Program\ Files\ \(x86\)/Brick\ Hill/legacy_autoupdater.exe
}
echo "Welcome to the Brick Hill Linux installer!"
echo "type 1 to install Brick Hill"
echo "type 2 to kill processes in prefix"
echo "then press enter"
read what
case $what in
1)
echo "Selected to install Brick Hill"
check_dependencies
download_game_base
download_game
desktop_file
url_handler_base
url_handler
resync_databases
install_winetricks_dependencies
run_updater
echo "Done!"
;;
2)
echo "Selected to kill processes in prefix"
kill_processes
;;
esac