2022-07-03 14:57:21 -06:00
#!/bin/bash
2023-11-12 23:09:00 -07:00
mkdir -p $HOME /.local/share/brick-hill-prefix
WINEPREFIXX = $HOME /.local/share/brick-hill-prefix
2022-07-16 21:49:06 -06:00
2022-07-17 13:04:59 -06:00
# To change what WINE that is used, specify the path. An example would be wine-tkg/bin/wine
WINEBIN = Default
2022-07-29 20:49:46 -06:00
# Variables for known Polygon install locations
2023-11-12 23:09:00 -07:00
BRICKHILLPATH = $WINEPREFIXX /drive_c/users/$USER /AppData/Roaming/Brick\ Hill
2022-07-24 21:31:45 -06:00
2022-07-17 13:04:59 -06:00
if [ [ ( $WINEBIN = = Default) ] ] ; then
WINEBIN = $( which wine)
else
echo "Warning: using custom wine binary"
fi
2022-07-16 21:49:06 -06:00
#Dependencies
fedora_install ( ) {
sudo dnf install wine winetricks
}
ubuntu_install ( ) {
sudo apt install wine winetricks
}
debian_install ( ) {
2022-07-21 18:51:43 -06:00
sudo apt install wine-development winetricks
2022-07-16 21:49:06 -06:00
}
arch_install ( ) {
sudo pacman -S --needed wine winetricks
}
2023-11-12 23:09:00 -07:00
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
2022-07-16 21:49:06 -06:00
}
2022-07-17 13:04:59 -06:00
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
}
2023-11-12 23:09:00 -07:00
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!"
2022-07-29 20:49:46 -06:00
}
2022-07-16 21:49:06 -06:00
#Creates .desktop files
2023-11-12 23:09:00 -07:00
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
2022-07-16 21:49:06 -06:00
2023-11-12 23:09:00 -07:00
echo "Created Brick Hill desktop file!"
2022-07-16 21:49:06 -06:00
}
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
}
2023-11-12 23:09:00 -07:00
url_handler ( ) {
MIMEENTRY = " $MIMETYPE = $( basename " $DESKTOPFILE " ) "
if grep -Fxq " $MIMEENTRY " " $MIMEAPPS "
2022-07-16 21:49:06 -06:00
then
echo "URL handler for 10 is already created! Skipping..."
else
2023-11-12 23:09:00 -07:00
echo $MIMEENTRY >> $MIMEAPPS
echo "Created URL handler for Brick Hill!"
2022-07-16 21:49:06 -06:00
fi
}
install_winetricks_dependencies ( ) {
2023-11-12 23:09:00 -07:00
env WINEPREFIX = $WINEPREFIXX winetricks --unattended dotnet40 gdiplus
2022-07-16 21:49:06 -06:00
}
resync_databases ( ) {
update-desktop-database " $HOME /.local/share/applications "
update-mime-database " $HOME /.local/share/mime "
echo "Synced desktop and mime databases"
}
2022-07-17 13:04:59 -06:00
kill_processes ( ) {
env WINEPREFIX = $WINEPREFIXX " $WINEBIN " server -k
}
2023-11-12 23:09:00 -07:00
run_updater ( ) {
env WINEPREFIX = $WINEPREFIXX $WINEBIN $WINEPREFIXX /drive_c/Program\ Files\ \( x86\) /Brick\ Hill/legacy_autoupdater.exe
}
2023-11-13 16:44:02 -07:00
run_workshop ( ) {
env WINEPREFIX = $WINEPREFIXX $WINEBIN " $BRICKHILLPATH /Workshop.exe "
}
2023-11-12 23:09:00 -07:00
echo "Welcome to the Brick Hill Linux installer!"
echo "type 1 to install Brick Hill"
2023-11-13 16:44:02 -07:00
echo "type 2 to open the Workshop"
echo "type 3 to kill processes in prefix"
2022-07-16 21:49:06 -06:00
echo "then press enter"
read what
2023-11-12 23:09:00 -07:00
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)
2023-11-13 16:44:02 -07:00
echo "Selected to open Workshop!"
run_workshop
; ;
3)
2023-11-12 23:09:00 -07:00
echo "Selected to kill processes in prefix"
kill_processes
; ;
esac