mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
refactor golang scripts a bit
Namely ensure the script fails if any step fails, only skip installing if that particular version is installed, and retry if the download fails
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
function install_go() {
|
||||
local go_version="1.15.5"
|
||||
local download=
|
||||
local download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
|
||||
|
||||
download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
|
||||
|
||||
if [ -d /usr/local/go ] ; then
|
||||
if go version 2>&1 | grep -q "${go_version}"; then
|
||||
return
|
||||
fi
|
||||
|
||||
curl -sSL --fail -o /tmp/go.tar.gz ${download}
|
||||
# remove previous older version
|
||||
rm -rf /usr/local/go
|
||||
|
||||
# retry downloading on spurious failure
|
||||
curl -sSL --fail -o /tmp/go.tar.gz \
|
||||
--retry 5 --retry-connrefused \
|
||||
"${download}"
|
||||
|
||||
tar -C /tmp -xf /tmp/go.tar.gz
|
||||
sudo mv /tmp/go /usr/local
|
||||
@@ -18,7 +24,7 @@ function install_go() {
|
||||
}
|
||||
|
||||
install_go
|
||||
|
||||
|
||||
# Ensure that the GOPATH tree is owned by vagrant:vagrant
|
||||
mkdir -p /opt/gopath
|
||||
chown -R vagrant:vagrant /opt/gopath
|
||||
|
||||
Reference in New Issue
Block a user