#!/usr/bin/env bash # Zeus self-hosted installer bootstrap. # # Kept tiny and portable on purpose (design doc: build-plan/13-self-hosted-install.md). # All real logic lives in the zeus-install Go binary this script downloads and # execs; this script only does what a static binary can't do for itself: # - detect distro + arch # - install Docker engine + compose plugin if missing (get.docker.com) # - enable docker on boot # - download the right zeus-install binary and exec it, forwarding argv + # stdin from the real terminal (so prompts still work under `curl | bash`) # # Usage: curl -fsSL https://get.zeusk8s.com/install.sh | bash -s -- [zeus-install flags] set -euo pipefail BASE_URL="${ZEUS_INSTALL_BASE_URL:-https://get.zeusk8s.com}" log() { printf '==> %s\n' "$*" >&2; } die() { printf 'error: %s\n' "$*" >&2; exit 1; } # --- arch detection ----------------------------------------------------- detect_arch() { case "$(uname -m)" in x86_64|amd64) echo amd64 ;; aarch64|arm64) echo arm64 ;; *) die "unsupported architecture $(uname -m) (zeus-install supports amd64/arm64 linux only)" ;; esac } # --- distro detection (informational + docker-install branch) ---------- detect_distro() { if [ -r /etc/os-release ]; then # shellcheck disable=SC1091 . /etc/os-release echo "${ID:-unknown}" else echo unknown fi } # --- tty helpers (curl | bash means stdin is the script, not a terminal) -- tty_prompt_yes_no() { local prompt="$1" default="${2:-n}" ans if [ ! -e /dev/tty ]; then echo "$default" return fi printf '%s [y/N]: ' "$prompt" > /dev/tty read -r ans < /dev/tty || ans="" case "$ans" in y|Y|yes|YES) echo y ;; *) echo "$default" ;; esac } # --- docker install ------------------------------------------------------ docker_present() { command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1 } install_docker() { log "Docker (with the compose plugin) was not found." if [ "$(tty_prompt_yes_no 'Install Docker now via get.docker.com?' y)" != "y" ]; then die "Docker is required. Install it yourself, then re-run this installer." fi log "installing Docker via get.docker.com ..." curl -fsSL https://get.docker.com | sh if command -v systemctl >/dev/null 2>&1; then systemctl enable --now docker fi } # --- main ----------------------------------------------------------------- main() { local arch distro skip_docker=0 arg arch="$(detect_arch)" distro="$(detect_distro)" log "detected linux/${arch} (${distro})" # --skip-docker-install is also a zeus-install flag (forwarded below as-is); # recognize it here too so the bootstrap doesn't install Docker only to # have the operator not want that. for arg in "$@"; do [ "$arg" = "--skip-docker-install" ] && skip_docker=1 done if [ "$skip_docker" != "1" ] && ! docker_present; then install_docker fi if command -v systemctl >/dev/null 2>&1; then systemctl enable --now docker >/dev/null 2>&1 || true fi local bin_url tmp_bin bin_url="${BASE_URL}/bin/zeus-install-linux-${arch}" tmp_bin="$(mktemp -t zeus-install.XXXXXX)" trap 'rm -f "$tmp_bin"' EXIT log "downloading ${bin_url}" curl -fsSL -o "$tmp_bin" "$bin_url" chmod +x "$tmp_bin" log "starting zeus-install" if [ -e /dev/tty ]; then exec "$tmp_bin" "$@" < /dev/tty else exec "$tmp_bin" "$@" fi } main "$@"