From f2ac62bf18482332a40e326b926a9790e5eaba01 Mon Sep 17 00:00:00 2001 From: liberodark Date: Wed, 13 Nov 2019 21:54:26 +0100 Subject: [PATCH] Update run.sh (#151) * Update run.sh --- run.sh | 82 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/run.sh b/run.sh index fec95999..b38b8cf1 100755 --- a/run.sh +++ b/run.sh @@ -3,51 +3,71 @@ # About: Build OpenDiablo 2 automatically # Author: liberodark # License: GNU GPLv3 -set -eu -version="0.0.2" +version="0.0.6" echo "OpenDiablo 2 Build Script $version" #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST AND VAR #================================================= +export PATH=$PATH:/usr/local/go/bin -distro=$(sed -n 's#PRETTY_NAME="\([^"]*\)"#\1#p' /etc/os-release) +distribution=$(cat /etc/*release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $1}') -# 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 +go_install(){ + # Check OS & go - 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 + 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 + + if [ "$distribution" = "CentOS" ] || [ "$distribution" = "Red\ Hat" ] || [ "$distribution" = "Suse" ] || [ "$distribution" = "Oracle" ]; then + echo "Downloading Go" + wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Install Go" + sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Clean unless files" + rm go*.linux-amd64.tar.gz + echo "Install libraries" + 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 + echo "Downloading Go" + wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Install Go" + sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Clean unless files" + rm go*.linux-amd64.tar.gz + echo "Install libraries" + 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 + echo "Downloading Go" + wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Install Go" + sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz > /dev/null 2>&1 + echo "Clean unless files" + rm go*.linux-amd64.tar.gz + echo "Install libraries" + 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 go libXcursor libXrandr libXinerama libXi libGLw libglvnd libsdl2 alsa-lib + + elif [ "$distribution" = "Manjaro" ] || [ "$distribution" = "Arch\ Linux" ]; then + sudo pacman -S go libxcursor libxrandr libxinerama libxi mesa libglvnd sdl2 sdl2_mixer sdl2_net alsa-lib --noconfirm + + fi fi +} # Build +echo "Check Go" +go_install echo "Build OpenDiablo 2" go get go build