forked from chadit/dotfiles_old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_go.sh
executable file
·45 lines (36 loc) · 1.14 KB
/
install_go.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Go Setup
func ()
{
local INSTALLVER=1.9
local SCRIPTUSER=${SUDO_USER}
local FILETAR="go${INSTALLVER}.linux-amd64.tar.gz"
local UNTARFOLDERNAME="go"
local INSTALLPATH="/usr/lib64/golang"
local SOURCEURL="https://storage.googleapis.com/golang/${FILETAR}"
# setup folders
if [ ! -f ${INSTALLPATH} ]; then
sudo mkdir -p ${INSTALLPATH}
# make folders to build windows exe's on linux
sudo mkdir -p ${INSTALLPATH}/pkg/windows_amd64
sudo mkdir -p ${INSTALLPATH}/pkg/windows_amd64/runtime
sudo mkdir -p ${INSTALLPATH}/pkg/windows_amd64/runtime/internal/
sudo chown -R chadit ${INSTALLPATH}/pkg/windows_amd64
fi
if test "$SCRIPTUSER" = "" || test "$SCRIPTUSER" = "root"; then
SCRIPTUSER=${USER}
fi
echo "user set to $SCRIPTUSER"
# change directory to tmp
cd /tmp/
# Download the sources if file does not exist
if [ ! -f /tmp/${FILETAR} ]; then
sudo wget ${SOURCEURL}
fi
# unpack tar
sudo tar -xvf ${FILETAR}
# Install to /usr/local
sudo rsync -av ${UNTARFOLDERNAME}/ ${INSTALLPATH}/
sudo rm -rf go*
}
func