2019-11-10 07:47:55 -05:00
|
|
|
#!/bin/sh
|
2019-11-10 01:32:59 -05:00
|
|
|
#
|
|
|
|
# About: Build OpenDiablo 2 automatically
|
|
|
|
# Author: liberodark
|
|
|
|
# License: GNU GPLv3
|
2019-11-10 07:47:55 -05:00
|
|
|
set -eu
|
2019-11-10 01:32:59 -05:00
|
|
|
|
2019-11-10 07:47:55 -05:00
|
|
|
version="0.0.2"
|
2019-11-10 01:32:59 -05:00
|
|
|
|
|
|
|
echo "OpenDiablo 2 Build Script $version"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST AND VAR
|
|
|
|
#=================================================
|
|
|
|
|
2019-11-10 07:47:55 -05:00
|
|
|
distro=$(sed -n 's#PRETTY_NAME="\([^"]*\)"#\1#p' /etc/os-release)
|
|
|
|
|
|
|
|
# Check OS & go
|
|
|
|
|
|
|
|
if ! command -v go >/dev/null
|
|
|
|
then
|
|
|
|
echo "Install Go for OpenDiablo 2 ($distro)? y/n"
|
|
|
|
read -r choice
|
|
|
|
[ "$choice" != y ] && [ "$choice" != Y ] && exit
|
|
|
|
|
|
|
|
case "$(echo "$distro" | tr '[:upper:]' '[:lower:]')" in
|
|
|
|
centos|red\ hat|suse|oracle)
|
|
|
|
sudo yum install -y go >/dev/null 2>&1
|
|
|
|
;;
|
|
|
|
fedora)
|
|
|
|
sudo dnf install -y go >/dev/null 2>&1
|
|
|
|
;;
|
|
|
|
debian|ubuntu|deepin)
|
|
|
|
sudo apt-get update >/dev/null 2>&1
|
|
|
|
sudo apt-get install -y go --force-yes >/dev/null 2>&1
|
|
|
|
;;
|
|
|
|
manjaro|arch\ linux)
|
|
|
|
sudo pacman -S go --noconfirm >/dev/null 2>&1
|
|
|
|
;;
|
|
|
|
gentoo/linux)
|
|
|
|
sudo emerge --ask n go /dev/null 2>&1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "$distro: unsupported distribution, please install Go by yourself"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2019-11-10 01:32:59 -05:00
|
|
|
fi
|
|
|
|
|
2019-11-10 07:47:55 -05:00
|
|
|
# Build
|
|
|
|
echo "Build OpenDiablo 2"
|
|
|
|
go get
|
|
|
|
go build
|
|
|
|
chmod u+x OpenDiablo2
|
|
|
|
echo "Build finished. Please edit config.json before running OpenDiablo2"
|