#!/bin/bash # Space Router - official CC Switch bootstrap for macOS 12+. No key handling. set -euo pipefail sr_completion_exit() { sr_code=$? if [ "$sr_code" -ne 0 ]; then printf '\nRESULT: FAILED / INCOMPLETE (exit %s). Read the error above.\n' "$sr_code" >&2; fi } trap sr_completion_exit EXIT download_only=0 no_launch=0 for arg in "$@"; do case "$arg" in --download-only) download_only=1 ;; --no-launch) no_launch=1 ;; *) echo "Unknown option: $arg" >&2; exit 2 ;; esac done if [ "$(uname -s)" != Darwin ]; then echo 'This installer requires macOS 12 or later.' >&2; exit 1; fi major=$(sw_vers -productVersion | cut -d. -f1) if [ "$major" -lt 12 ]; then echo 'CC Switch requires macOS 12 or later.' >&2; exit 1; fi stage=$(mktemp -d "${TMPDIR:-/tmp}/sr-ccswitch.XXXXXX") trap 'sr_code=$?; rm -f "$stage/cc-switch.zip"; if [ "$sr_code" -ne 0 ]; then printf "RESULT: FAILED / INCOMPLETE (exit %s). Read the error above.\n" "$sr_code" >&2; fi' EXIT url='https://github.com/farion1231/cc-switch/releases/download/v4.0.16/CC-Switch-v4.0.16-macOS.zip' sha='d1fd14c5428a9e1b458f1782607a38665356897728e7e2c437c5da6b6f2034ac' echo 'Space Router: downloading official CC Switch 4.0.16 for macOS...' curl --fail --location --progress-bar --proto '=https' --tlsv1.2 "$url" -o "$stage/cc-switch.zip" actual=$(shasum -a 256 "$stage/cc-switch.zip" | awk '{print $1}') if [ "$actual" != "$sha" ]; then echo 'SHA256 mismatch. Installation stopped.' >&2; exit 1; fi echo 'Official package SHA256 verified.' if [ "$download_only" -eq 1 ]; then echo 'Download-only check passed. No installation or launch.'; exit 0; fi # Existing installs are left in place. Use CC Switch itself for updates. app='' for existing in "$HOME/Applications/CC Switch.app" '/Applications/CC Switch.app'; do if [ -d "$existing" ]; then app=$existing; break; fi done if [ -z "$app" ]; then ditto -x -k "$stage/cc-switch.zip" "$stage/unpacked" source_app=$(find "$stage/unpacked" -maxdepth 2 -name '*.app' -type d -print -quit) if [ -z "$source_app" ]; then echo 'Official archive contains no application.' >&2; exit 1; fi /usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$source_app/Contents/Info.plist" | grep -qx 'com.ccswitch.desktop' mkdir -p "$HOME/Applications" app="$HOME/Applications/CC Switch.app" ditto "$source_app" "$app" echo 'Installed in ~/Applications/CC Switch.app.' else echo "Keeping existing installation: $app" fi if [ "$no_launch" -eq 0 ]; then open "$app" open 'https://space.stationine.com/keys' fi echo 'Approve the normal macOS app prompt if shown. No Gatekeeper settings are changed.' echo 'Space Router > API Keys > Import to CC Switch. Review the endpoint and confirm in the app.' echo 'Claude Code and Codex CLI have separate setup guides if you need to install those clients.' printf 'INSTALLATION: DONE / CC Switch app is present.\nCONNECTION: NOT CONFIGURED. Import your own provider and test it in the client.\n'