#!/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= installs that version instead of main # SUPASPIN_SRC= installs from a local checkout instead of downloading # SUPASPIN_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=," >&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"