bladerunner/tools/install-go.sh

53 lines
1.0 KiB
Bash
Raw Normal View History

2023-04-10 01:31:44 +00:00
#!/usr/bin/env bash
set -euxo pipefail
INSTALL_DIR="/usr/local/bin"
GOVERSION=1.20.3
2023-04-10 04:55:39 +00:00
ARCH=amd64
2023-04-10 01:31:44 +00:00
preflight () {
if [ "$(uname -s)" != "Linux" ]
then
echo '[!] godeb is only supported on Linux.' > /dev/stderr
exit 1
fi
case "$(uname -m)" in
amd64) ARCH="amd64" ;;
arm64) ARCH="arm64" ;;
*)
echo "[!] $(uname -m) is an unsupported architecture." > /dev/stderr
echo '[!] supported architectures: amd64, arm64' > /dev/stderr
2023-04-10 04:55:39 +00:00
exit 1
2023-04-10 01:31:44 +00:00
;;
esac
}
install_godeb () {
2023-04-10 04:55:39 +00:00
local GODEB=https://godeb.s3.amazonaws.com/godeb-${ARCH}.tar.gz
2023-04-10 01:31:44 +00:00
if [ -x "${INSTALL_DIR}/godeb" ]
then
return 0
fi
local GODEB_ARCHIVE="${GODEB##*/}"
pushd /tmp
curl -LO "${GODEB}"
tar xzf "${GODEB_ARCHIVE}"
sudo mv godeb "${INSTALL_DIR}/"
rm "${GODEB_ARCHIVE}"
popd
}
install_go {
pushd /tmp
echo '[*] installing go - this will request sudo'
godeb install "${GOVERSION}"
# note: deliberately leaving this in /tmp for inspection
# if needed.
popd
}