photoprism/scripts/dist/install-go.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2022-02-18 17:40:58 +01:00
#!/usr/bin/env bash
GOLANG_VERSION=1.17.7
DESTDIR=$(realpath "${1:-/usr/local}")
# abort if the user is not root
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
2022-02-18 17:40:58 +01:00
exit 1
fi
echo "Installing Go in \"$DESTDIR\"..."
2022-02-18 17:40:58 +01:00
set -e
mkdir -p "$DESTDIR"
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
DESTARCH=${2:-$SYSTEM_ARCH}
2022-02-18 17:40:58 +01:00
set -eux;
if [[ $DESTARCH == "amd64" ]]; then
2022-02-18 17:40:58 +01:00
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"
CHECKSUM="02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259 *go.tgz"
elif [[ $DESTARCH == "arm64" ]]; then
2022-02-18 17:40:58 +01:00
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"
CHECKSUM="a5aa1ed17d45ee1d58b4a4099b12f8942acbd1dd09b2e9a6abb1c4898043c5f5 *go.tgz"
elif [[ $DESTARCH == "arm" ]]; then
2022-02-18 17:40:58 +01:00
URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
CHECKSUM="874774f078b182fa21ffcb3878467eb5cb7e78bbffa6343ea5f0fbe47983433b *go.tgz"
else
echo "Unsupported Machine Architecture: $DESTARCH" 1>&2
2022-02-18 17:40:58 +01:00
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."