2019-11-21 20:34:54 -05:00
|
|
|
#!/bin/bash
|
2019-11-10 01:32:59 -05:00
|
|
|
#
|
|
|
|
# About: Build OpenDiablo 2 automatically
|
|
|
|
# Author: liberodark
|
|
|
|
# License: GNU GPLv3
|
|
|
|
|
2019-12-02 16:57:47 -05:00
|
|
|
version="0.0.7"
|
2020-02-06 20:01:11 -05:00
|
|
|
go_version="1.13.4"
|
2019-11-10 01:32:59 -05:00
|
|
|
echo "OpenDiablo 2 Build Script $version"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST AND VAR
|
|
|
|
#=================================================
|
2019-11-13 15:54:26 -05:00
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
2019-11-10 01:32:59 -05:00
|
|
|
|
2019-11-13 15:54:26 -05:00
|
|
|
distribution=$(cat /etc/*release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $1}')
|
|
|
|
|
|
|
|
|
|
|
|
go_install(){
|
|
|
|
# Check OS & go
|
|
|
|
|
|
|
|
if ! command -v go > /dev/null 2>&1; then
|
|
|
|
|
|
|
|
echo "Install Go for OpenDiablo 2 ($distribution)? y/n"
|
|
|
|
read -r choice
|
|
|
|
[ "$choice" != y ] && [ "$choice" != Y ] && exit
|
|
|
|
|
2019-12-02 16:57:47 -05:00
|
|
|
if [ "$distribution" = "CentOS" ] || [ "$distribution" = "Red\ Hat" ] || [ "$distribution" = "Oracle" ]; then
|
2019-11-13 15:54:26 -05:00
|
|
|
echo "Downloading Go"
|
2020-02-06 20:01:11 -05:00
|
|
|
wget https://dl.google.com/go/go"$go_version".linux-amd64.tar.gz > /dev/null 2>&1
|
2019-11-13 15:54:26 -05:00
|
|
|
echo "Install Go"
|
|
|
|
sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1
|
2020-06-25 13:08:33 -04:00
|
|
|
echo "Clean unneeded files"
|
2019-11-13 15:54:26 -05:00
|
|
|
rm go*.linux-amd64.tar.gz
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Fedora" ]; then
|
|
|
|
echo "Downloading Go"
|
2020-02-06 20:01:11 -05:00
|
|
|
wget https://dl.google.com/go/go"$go_version".linux-amd64.tar.gz > /dev/null 2>&1
|
2019-11-13 15:54:26 -05:00
|
|
|
echo "Install Go"
|
|
|
|
sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1
|
2020-06-25 13:08:33 -04:00
|
|
|
echo "Clean unneeded files"
|
2019-11-13 15:54:26 -05:00
|
|
|
rm go*.linux-amd64.tar.gz
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Debian" ] || [ "$distribution" = "Ubuntu" ] || [ "$distribution" = "Deepin" ]; then
|
|
|
|
echo "Downloading Go"
|
2020-02-06 20:01:11 -05:00
|
|
|
wget https://dl.google.com/go/go"$go_version".linux-amd64.tar.gz > /dev/null 2>&1
|
2019-11-13 15:54:26 -05:00
|
|
|
echo "Install Go"
|
|
|
|
sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1
|
2020-06-25 13:08:33 -04:00
|
|
|
echo "Clean unneeded files"
|
2019-11-13 15:54:26 -05:00
|
|
|
rm go*.linux-amd64.tar.gz
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Gentoo" ]; then
|
2020-06-25 13:08:33 -04:00
|
|
|
sudo emerge --ask n go
|
2019-11-13 15:54:26 -05:00
|
|
|
|
|
|
|
elif [ "$distribution" = "Manjaro" ] || [ "$distribution" = "Arch\ Linux" ]; then
|
2020-06-25 13:08:33 -04:00
|
|
|
sudo pacman -S go --noconfirm
|
2019-12-02 16:57:47 -05:00
|
|
|
|
|
|
|
elif [ "$distribution" = "OpenSUSE" ] || [ "$distribution" = "SUSE" ]; then
|
|
|
|
echo "Downloading Go"
|
2020-02-06 20:01:11 -05:00
|
|
|
wget https://dl.google.com/go/go"$go_version".linux-amd64.tar.gz > /dev/null 2>&1
|
2019-12-02 16:57:47 -05:00
|
|
|
echo "Install Go"
|
|
|
|
sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1
|
2020-06-25 13:08:33 -04:00
|
|
|
echo "Clean unneeded files"
|
2019-12-02 16:57:47 -05:00
|
|
|
rm go*.linux-amd64.tar.gz
|
2019-11-13 15:54:26 -05:00
|
|
|
|
|
|
|
fi
|
2019-11-10 01:32:59 -05:00
|
|
|
fi
|
2019-11-13 15:54:26 -05:00
|
|
|
}
|
2019-11-10 01:32:59 -05:00
|
|
|
|
2020-06-25 13:08:33 -04:00
|
|
|
dep_install(){
|
|
|
|
if [ "$distribution" = "CentOS" ] || [ "$distribution" = "Red\ Hat" ] || [ "$distribution" = "Oracle" ]; then
|
|
|
|
sudo yum install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel alsa-lib-devel libXi-devel > /dev/null 2>&1
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Fedora" ]; then
|
|
|
|
sudo dnf install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel alsa-lib-devel libXi-devel > /dev/null 2>&1
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Debian" ] || [ "$distribution" = "Ubuntu" ] || [ "$distribution" = "Deepin" ]; then
|
|
|
|
sudo apt-get install -y libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libgl1-mesa-dev libsdl2-dev libasound2-dev > /dev/null 2>&1
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Gentoo" ]; then
|
|
|
|
sudo emerge --ask n libXcursor libXrandr libXinerama libXi libGLw libglvnd libsdl2 alsa-lib
|
|
|
|
|
|
|
|
elif [ "$distribution" = "Manjaro" ] || [ "$distribution" = "Arch\ Linux" ]; then
|
|
|
|
sudo pacman -S libxcursor libxrandr libxinerama libxi mesa libglvnd sdl2 sdl2_mixer sdl2_net alsa-lib --noconfirm
|
|
|
|
|
|
|
|
elif [ "$distribution" = "OpenSUSE" ] || [ "$distribution" = "SUSE" ]; then
|
|
|
|
sudo zypper install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel Mesa-libGL-devel alsa-lib-devel libXi-devel > /dev/null 2>&1
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-11-10 07:47:55 -05:00
|
|
|
# Build
|
2019-11-13 15:54:26 -05:00
|
|
|
echo "Check Go"
|
|
|
|
go_install
|
2020-06-25 13:08:33 -04:00
|
|
|
echo "Install libraries"
|
|
|
|
dep_install
|
2019-11-10 07:47:55 -05:00
|
|
|
echo "Build OpenDiablo 2"
|
2020-06-25 13:08:33 -04:00
|
|
|
go get -d
|
2019-11-10 07:47:55 -05:00
|
|
|
go build
|
|
|
|
echo "Build finished. Please edit config.json before running OpenDiablo2"
|