48 lines
No EOL
1.2 KiB
Bash
Executable file
48 lines
No EOL
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
GOLANG_VERSION=1.17.7
|
|
|
|
DESTDIR=$(realpath "${1:-/usr/local}")
|
|
|
|
# abort if not executed as root
|
|
if [[ $(id -u) != "0" ]]; then
|
|
echo "Usage: run ${0##*/} as root" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing Go in \"$DESTDIR\"..."
|
|
|
|
set -e
|
|
|
|
mkdir -p "$DESTDIR"
|
|
|
|
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
|
|
DESTARCH=${2:-$SYSTEM_ARCH}
|
|
|
|
set -eux;
|
|
|
|
if [[ $DESTARCH == "amd64" ]]; then
|
|
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"
|
|
CHECKSUM="02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259 *go.tgz"
|
|
elif [[ $DESTARCH == "arm64" ]]; then
|
|
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"
|
|
CHECKSUM="a5aa1ed17d45ee1d58b4a4099b12f8942acbd1dd09b2e9a6abb1c4898043c5f5 *go.tgz"
|
|
elif [[ $DESTARCH == "arm" ]]; then
|
|
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
|
|
CHECKSUM="874774f078b182fa21ffcb3878467eb5cb7e78bbffa6343ea5f0fbe47983433b *go.tgz"
|
|
else
|
|
echo "Unsupported Machine Architecture: $DESTARCH" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Downloading Go from \"$URL\". Please wait."
|
|
|
|
wget -O go.tgz $URL
|
|
echo $CHECKSUM | sha256sum -c -
|
|
rm -rf /usr/local/go
|
|
tar -C /usr/local -xzf go.tgz
|
|
rm go.tgz
|
|
|
|
/usr/local/go/bin/go version
|
|
|
|
echo "Done." |