Initial commit: Potatium
This commit is contained in:
commit
e2d0be22fd
58 files changed
+1551
No files matched your search
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verified Go installation for Potatium (Ubuntu 26.04 LTS); run as root.
|
||||
set -Eeuo pipefail
|
||||
if [[ $EUID -ne 0 ]]; then echo "Run as root: sudo bash scripts/install_go.sh" >&2; exit 1; fi
|
||||
GO_VERSION="1.27.3"
|
||||
case "$(dpkg --print-architecture)" in
|
||||
amd64) ARCH=amd64; SHA256='65efbc80fdc1fa2cd2631cad5b481777a68e8725f34e89f50fc6ac714e379b40';;
|
||||
arm64) ARCH=arm64; SHA256='a06e99309dbcbdca1a8ccd2282c3ee146e55930886e26b4f1193269587165f49';;
|
||||
*) echo 'Only Ubuntu amd64 and arm64 supported by this installer' >&2; exit 1;;
|
||||
esac
|
||||
ARCHIVE="go${GO_VERSION}.linux-${ARCH}.tar.gz"
|
||||
if [[ -x /usr/local/go/bin/go ]]; then
|
||||
EXISTING=$(/usr/local/go/bin/go version)
|
||||
if [[ "$EXISTING" == "go version go${GO_VERSION} "* ]]; then
|
||||
echo "Already installed: $EXISTING"; exit 0
|
||||
fi
|
||||
echo "Existing /usr/local/go detected: $EXISTING. Stop. Manually assess upgrade first." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -e /usr/local/go ]]; then
|
||||
echo '/usr/local/go already exists. Refusing to overwrite.' >&2; exit 1
|
||||
fi
|
||||
TEMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP"' EXIT
|
||||
printf 'Downloading verified Go %s for linux/%s\n' "$GO_VERSION" "$ARCH"
|
||||
curl --fail --location --show-error --silent --retry 3 \
|
||||
"https://go.dev/dl/${ARCHIVE}" -o "$TEMP/${ARCHIVE}"
|
||||
printf '%s %s\n' "$SHA256" "$TEMP/${ARCHIVE}" | sha256sum --check --status || {
|
||||
echo 'Checksum mismatch. Aborted.' >&2; exit 1;
|
||||
}
|
||||
tar -xzf "$TEMP/${ARCHIVE}" -C "$TEMP"
|
||||
# Install a fresh tree, never unpack on top of an existing installation.
|
||||
mv "$TEMP/go" /usr/local/go
|
||||
cat > /etc/profile.d/potatium-go.sh <<'ENDPATH'
|
||||
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
|
||||
ENDPATH
|
||||
ln -sfn /usr/local/go/bin/go /usr/local/bin/go
|
||||
ln -sfn /usr/local/go/bin/gofmt /usr/local/bin/gofmt
|
||||
/usr/local/go/bin/go version
|
||||
Reference in new issue
Block a user