Skip to content

Commit 9a112af

Browse files
author
Mahmood Ali
authored
Merge pull request #9567 from hashicorp/scripts-fail-on-golang-failure
scripts: fail if golang installation fails
2 parents de6b344 + e15fad5 commit 9a112af

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

scripts/release/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# that mimics Vagrant environment as far as required
33
# for building the scripts and running provision scripts
44

5-
FROM ubuntu:16.04
5+
FROM ubuntu:18.04
66

77
RUN apt-get update; apt-get install -y \
88
apt-transport-https \

scripts/vagrant-linux-priv-go.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
#!/usr/bin/env bash
22

3+
set -o errexit
4+
35
function install_go() {
46
local go_version="1.15.5"
5-
local download=
6-
7-
download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
7+
local download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz"
88

9-
if [ -d /usr/local/go ] ; then
9+
if go version 2>&1 | grep -q "${go_version}"; then
1010
return
1111
fi
1212

13-
curl -sSL --fail -o /tmp/go.tar.gz ${download}
13+
# remove previous older version
14+
rm -rf /usr/local/go
15+
16+
# retry downloading on spurious failure
17+
curl -sSL --fail -o /tmp/go.tar.gz \
18+
--retry 5 --retry-connrefused \
19+
"${download}"
1420

1521
tar -C /tmp -xf /tmp/go.tar.gz
1622
sudo mv /tmp/go /usr/local
1723
sudo chown -R root:root /usr/local/go
1824
}
1925

2026
install_go
21-
27+
2228
# Ensure that the GOPATH tree is owned by vagrant:vagrant
2329
mkdir -p /opt/gopath
2430
chown -R vagrant:vagrant /opt/gopath

0 commit comments

Comments
 (0)