#!/usr/bin/env bash set -euo pipefail DEFAULT_BASE_URL="https://get.orbnetes.cloud" ORBN_GET_BASE_URL="${ORBN_GET_BASE_URL:-$DEFAULT_BASE_URL}" ORBN_RELEASE_CHANNEL="${ORBN_RELEASE_CHANNEL:-stable}" usage() { cat <<'EOF' Orbnetes installer (latest stable wrapper) Usage: bash install.sh [installer args...] Environment: ORBN_GET_BASE_URL Base URL for installer assets (default: https://get.orbnetes.cloud) ORBN_RELEASE_CHANNEL Release channel key from latest.json (default: stable) Example: curl -fsSL https://get.orbnetes.cloud/install.sh | bash curl -fsSL https://get.orbnetes.cloud/install.sh | bash -s -- --app-url http://localhost:8080 EOF } if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then usage exit 0 fi require_cmd() { local c="$1" if ! command -v "$c" >/dev/null 2>&1; then echo "Required command not found: $c" exit 1 fi } require_cmd curl require_cmd bash LATEST_URL="${ORBN_GET_BASE_URL%/}/latest.json" latest_json="$(curl -fsSL "$LATEST_URL")" extract_version() { local json="$1" local channel="$2" if command -v jq >/dev/null 2>&1; then printf '%s' "$json" | jq -r --arg ch "$channel" '.[$ch] // empty' return fi # Fallback parser for simple flat JSON: {"stable":"1.8.0","beta":"1.9.0-beta.1"} printf '%s' "$json" \ | tr -d '\n' \ | sed -E 's/[[:space:]]+//g' \ | sed -nE "s/.*\"${channel}\":\"([^\"]+)\".*/\1/p" } version="$(extract_version "$latest_json" "$ORBN_RELEASE_CHANNEL")" if [ -z "$version" ]; then echo "Unable to resolve version for channel '${ORBN_RELEASE_CHANNEL}' from ${LATEST_URL}" exit 1 fi installer_url="${ORBN_GET_BASE_URL%/}/install-v${version}.sh" tmp_installer="$(mktemp -t orbnetes-install-XXXXXX.sh)" trap 'rm -f "$tmp_installer"' EXIT echo "Resolved ${ORBN_RELEASE_CHANNEL} -> v${version}" echo "Downloading ${installer_url}" curl -fsSL "$installer_url" -o "$tmp_installer" chmod +x "$tmp_installer" exec bash "$tmp_installer" "$@"