Files
IgorandClaude Opus 5 99fdf7a0ab fix: write the repository's real address in the docs
The repository is owned by the organisation `public`, not by the user `igor`.
Gitea forwards the old address for anything a browser or git does, so the install
command and the clone lines kept working and the wrong address went unnoticed.

An API call is the exception. A POST to `/api/v1/repos/igor/supaspin/...` is
answered with a redirect that curl does not follow for a POST, so the command
returns an empty body and no error - which reads as a rejected token. Creating
the v1.2.0 tag and opening its pull request both failed this way first.

- CLAUDE.md: the tagging rule now names `public` and says why an API address
  cannot use the forwarded one.
- README.md, install.sh: the install, token and clone commands now use the
  address the server actually serves.

Version 1.2.0 -> 1.2.1. No change to what the program does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 21:58:53 +03:00

70 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# One-line install (run on the Kubernetes server):
# curl -fsSL https://git.didgibot.com/public/supaspin/raw/branch/main/install.sh | sudo bash
# Installs /usr/local/bin/supaspin and its Helm values template. Safe to run again to upgrade.
#
# If your Gitea requires sign-in even for public repositories, give a read-only token:
# curl -fsSL -H "Authorization: token $TOKEN" .../install.sh | sudo SUPASPIN_TOKEN=$TOKEN bash
# or clone the repository and run `sudo bash install.sh` from inside the checkout.
#
# SUPASPIN_REF=<branch or tag> installs that version instead of main
# SUPASPIN_SRC=<folder> installs from a local checkout instead of downloading
# SUPASPIN_TOKEN=<token> Gitea token (read access to the repository) for the download
set -euo pipefail
REPO="https://git.didgibot.com/public/supaspin"
REF="${SUPASPIN_REF:-main}"
[ "$(id -u)" -eq 0 ] || { echo "Run as root: curl -fsSL $REPO/raw/branch/main/install.sh | sudo bash" >&2; exit 1; }
# python3 and its YAML module are the only runtime dependencies.
command -v python3 >/dev/null || { echo "python3 is required" >&2; exit 1; }
if ! python3 -c 'import yaml' 2>/dev/null; then
echo "Installing python3-yaml with apt..."
apt-get install -y python3-yaml
fi
# kubectl and helm: the microk8s snap commands, or plain ones.
if [ ! -x /snap/bin/microk8s.kubectl ] && ! command -v kubectl >/dev/null; then
echo "kubectl not found (on microk8s: sudo snap install microk8s --classic)" >&2; exit 1
fi
if [ ! -x /snap/bin/microk8s.helm3 ] && ! command -v helm >/dev/null; then
echo "helm not found (on microk8s: sudo microk8s enable helm3)" >&2; exit 1
fi
# Where to install from: an explicit folder, the checkout this script sits in, or a download.
here="$(cd "$(dirname "${BASH_SOURCE[0]:-/nonexistent}")" 2>/dev/null && pwd || true)"
if [ -n "${SUPASPIN_SRC:-}" ]; then
src="$SUPASPIN_SRC"
elif [ -n "$here" ] && [ -f "$here/supaspin" ] && [ -f "$here/templates/values.yaml.tpl" ]; then
src="$here"
else
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
echo "Downloading supaspin ($REF)..."
auth=()
[ -n "${SUPASPIN_TOKEN:-}" ] && auth=(-H "Authorization: token $SUPASPIN_TOKEN")
curl -fsSL "${auth[@]}" -o "$tmp/src.tar.gz" "$REPO/archive/$REF.tar.gz" || true
if ! gzip -t "$tmp/src.tar.gz" 2>/dev/null; then
echo "Could not download $REPO/archive/$REF.tar.gz." >&2
echo "If the server asks for sign-in, rerun with SUPASPIN_TOKEN=<read-only token>," >&2
echo "or clone the repository and run 'sudo bash install.sh' inside it." >&2
exit 1
fi
tar -xzf "$tmp/src.tar.gz" -C "$tmp"
src="$(find "$tmp" -mindepth 1 -maxdepth 1 -type d | head -1)"
fi
for f in supaspin templates/values.yaml.tpl uninstall.sh; do
[ -f "$src/$f" ] || { echo "$src/$f is missing: not a supaspin checkout" >&2; exit 1; }
done
install -m 0755 "$src/supaspin" /usr/local/bin/supaspin
install -d -m 0755 /usr/share/supaspin/templates
install -m 0644 "$src/templates/values.yaml.tpl" /usr/share/supaspin/templates/values.yaml.tpl
install -m 0755 "$src/uninstall.sh" /usr/share/supaspin/uninstall.sh
install -d -m 0700 /etc/supaspin /var/lib/supaspin
echo "Installed $(/usr/local/bin/supaspin --version)."
echo "Next: run 'sudo supaspin' - the first run asks for your settings."
echo "To remove it later: sudo bash /usr/share/supaspin/uninstall.sh"