#!/bin/sh # setup.sh - OS dispatcher for the 759705.cc bootstrap scripts. # # Purpose : Detect the current operating system and hand off to the matching # bootstrap script, so there is exactly one URL to remember. # Usage : curl -fsSL https://759705.cc/setup.sh | sh # Idempotent: yes. This script only detects and dispatches; the script it calls # checks every step before acting, so re-running is always safe. # Dry run : HUB_DRY_RUN=1 prints what would happen and downloads/runs nothing. # HUB_DRY_RUN=1 sh setup.sh # Local test: HUB_BASE overrides the base URL. # HUB_BASE=http://localhost:4321 HUB_DRY_RUN=1 sh setup.sh # # Contains no secrets and no internal hostnames; safe to serve publicly. set -eu HUB_BASE="${HUB_BASE:-https://759705.cc}" HUB_DRY_RUN="${HUB_DRY_RUN:-0}" log() { printf '==> %s\n' "$*"; } note() { printf ' %s\n' "$*"; } warn() { printf '!! %s\n' "$*" >&2; } main() { os="$(uname -s 2>/dev/null || echo unknown)" log "hub setup - detected system: ${os}" case "$os" in Darwin) log "macOS detected. Handing off to ${HUB_BASE}/mac.sh" if [ "$HUB_DRY_RUN" = "1" ]; then printf 'DRY curl -fsSL %s/mac.sh | sh\n' "$HUB_BASE" note "Dry run: nothing was downloaded and nothing was executed." return 0 fi if ! command -v curl >/dev/null 2>&1; then warn "curl is required but was not found on PATH." return 1 fi # Pass HUB_BASE through so the child script resolves against the same host. curl -fsSL "$HUB_BASE/mac.sh" | HUB_BASE="$HUB_BASE" HUB_DRY_RUN="$HUB_DRY_RUN" sh ;; Linux) log "Linux detected." note "There is no generic Linux baseline script yet." note "Manual steps: ${HUB_BASE}/commands/linux/" note "Clash Verge Rev on Ubuntu desktop (needs a subcommand, see usage):" note " curl -fsSL ${HUB_BASE}/clash.sh | sh -s -- all" return 0 ;; CYGWIN* | MINGW* | MSYS* | Windows_NT) log "Windows detected (POSIX compatibility layer)." note "Run this in PowerShell 5.1 or newer instead:" note " irm ${HUB_BASE}/win.ps1 | iex" return 0 ;; *) warn "Unsupported system: ${os}" note "Supported: macOS (${HUB_BASE}/mac.sh), Windows (${HUB_BASE}/win.ps1)." note "On Windows run: irm ${HUB_BASE}/win.ps1 | iex" return 0 ;; esac } main "$@"