github.com/rohankumardubey/nomad@v0.11.8/scripts/vagrant-linux-priv-go.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  function install_go() {
     4  	local go_version="1.14.6"
     5  	local download=
     6  
     7  	download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
     8  
     9  	if [ -d /usr/local/go ] ; then
    10  		return
    11  	fi
    12  
    13  	curl -sSL --fail -o /tmp/go.tar.gz ${download}
    14  
    15  	tar -C /tmp -xf /tmp/go.tar.gz
    16  	sudo mv /tmp/go /usr/local
    17  	sudo chown -R root:root /usr/local/go
    18  }
    19  
    20  install_go
    21  	
    22  # Ensure that the GOPATH tree is owned by vagrant:vagrant
    23  mkdir -p /opt/gopath
    24  chown -R vagrant:vagrant /opt/gopath
    25  
    26  # Ensure Go is on PATH
    27  if [ ! -e /usr/bin/go ] ; then
    28  	ln -s /usr/local/go/bin/go /usr/bin/go
    29  fi
    30  if [ ! -e /usr/bin/gofmt ] ; then
    31  	ln -s /usr/local/go/bin/gofmt /usr/bin/gofmt
    32  fi
    33  
    34  
    35  # Ensure new sessions know about GOPATH
    36  if [ ! -f /etc/profile.d/gopath.sh ] ; then
    37  	cat <<EOT > /etc/profile.d/gopath.sh
    38  export GOPATH="/opt/gopath"
    39  export PATH="/opt/gopath/bin:\$PATH"
    40  EOT
    41  	chmod 755 /etc/profile.d/gopath.sh
    42  fi