forked from hashicorp/nomad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Install Go in Vagrant from official release
- Loading branch information
Showing
3 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
function install_go() { | ||
local go_version=1.9 | ||
local download= | ||
|
||
download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz" | ||
|
||
if [ -d /usr/local/go ] ; then | ||
return | ||
fi | ||
|
||
wget -q -O /tmp/go.tar.gz ${download} | ||
|
||
tar -C /tmp -xvf /tmp/go.tar.gz | ||
sudo mv /tmp/go /usr/local | ||
sudo chown -R root:root /usr/local/go | ||
} | ||
|
||
install_go | ||
|
||
# Ensure that the GOPATH tree is owned by vagrant:vagrant | ||
mkdir -p /opt/gopath | ||
chown vagrant:vagrant \ | ||
/opt/gopath \ | ||
/opt/gopath/src \ | ||
/opt/gopath/src/github.com \ | ||
/opt/gopath/src/github.com/hashicorp | ||
|
||
# Ensure Go is on PATH | ||
if [ ! -e /usr/bin/go ] ; then | ||
ln -s /usr/local/go/bin/go /usr/bin/go | ||
fi | ||
if [ ! -e /usr/bin/gofmt ] ; then | ||
ln -s /usr/local/go/bin/gofmt /usr/bin/gofmt | ||
fi | ||
|
||
|
||
# Ensure new sessions know about GOPATH | ||
if [ ! -f /etc/profile.d/gopath.sh ] ; then | ||
cat <<EOT > /etc/profile.d/gopath.sh | ||
export GOPATH="/opt/gopath" | ||
export PATH="/opt/gopath/bin:\$PATH" | ||
EOT | ||
chmod 755 /etc/profile.d/gopath.sh | ||
fi |