Files
supaspin/install.sh
T
Igor K.andClaude Sonnet 5 45b02a85af fix: installer prints the name once; add CLAUDE.md with the versioning rule
- install.sh said "Installed supaspin supaspin 1.1.0." because --version now includes the name; it now says
  "Installed supaspin 1.1.1."
- CLAUDE.md: tells AI agents to read Igor's global rules first, and states the versioning rule (number in VERSION,
  code and README together, semantic versioning, major bumps only with Igor's yes, a git tag vX.Y.Z after every merge)
- version 1.1.0 -> 1.1.1

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-19 12:27:11 +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/igor/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/igor/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"