#!/usr/bin/env sh # Offsync install bootstrap. # # curl -fsSL https://offsync.app/install.sh | sh # # Idempotent. Doesn't require sudo. Works on macOS + Linux today; Windows # lands at M4 with a parallel install.ps1. # # What it does: # 1. Detects platform (darwin | linux). Bails on unsupported OSes. # 2. Checks for Node 20+. If absent, installs via nvm (no sudo, no # package-manager assumption — nvm writes to $HOME/.nvm/). # 3. Runs `npm install -g offsync`. # 4. Tells the user to run `offsync start`. # # Re-running is safe: it skips already-satisfied steps and never overwrites # a working Node install. set -eu log() { printf '\033[35m[offsync]\033[0m %s\n' "$1" >&2; } err() { printf '\033[31m[offsync error]\033[0m %s\n' "$1" >&2; exit 1; } # ── 1. Platform check ──────────────────────────────────────────────────── OS="$(uname -s | tr '[:upper:]' '[:lower:]')" case "$OS" in darwin) PLATFORM="macOS" ;; linux) PLATFORM="Linux" ;; *) err "Unsupported platform: $OS. Offsync ships for macOS today, Linux daemon-only, Windows at M4." ;; esac log "Detected $PLATFORM." # Architecture sanity. Offsync's Mac daemon is Apple Silicon only right now. ARCH="$(uname -m)" if [ "$OS" = "darwin" ] && [ "$ARCH" != "arm64" ]; then err "Offsync's macOS daemon is Apple Silicon (arm64) only. You're on $ARCH. Intel support is not on the roadmap — see INSTALLATION_PREFERENCES.md." fi # ── 2. Node 20+ check ──────────────────────────────────────────────────── NEED_NODE="true" if command -v node >/dev/null 2>&1; then NODE_MAJOR="$(node -v 2>/dev/null | sed -n 's/^v\([0-9][0-9]*\).*$/\1/p')" if [ -n "$NODE_MAJOR" ] && [ "$NODE_MAJOR" -ge 20 ] 2>/dev/null; then log "Node $(node -v) already installed — skipping Node install." NEED_NODE="false" else log "Node present but older than 20 ($(node -v)) — will install Node 20 via nvm into your user home." fi fi # ── 3. Install Node via nvm if missing ─────────────────────────────────── if [ "$NEED_NODE" = "true" ]; then if [ ! -d "${HOME}/.nvm" ]; then log "Installing nvm into ~/.nvm (no sudo required)…" # PROFILE=/dev/null prevents nvm from auto-editing your shell rc files — # we source it ourselves below for the duration of this install. PROFILE=/dev/null curl -fsSL \ https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash >/dev/null else log "nvm already present at ~/.nvm — skipping nvm install." fi # Load nvm into THIS shell (it's an init function, not on PATH). export NVM_DIR="${HOME}/.nvm" # shellcheck disable=SC1091 . "${NVM_DIR}/nvm.sh" log "Installing Node 20 (LTS) via nvm…" nvm install 20 >/dev/null nvm use 20 >/dev/null log "Node $(node -v) installed." cat >&2 </dev/null # ── 5. Done ────────────────────────────────────────────────────────────── cat >&2 <<'EOF' Offsync is installed. offsync start # launch the daemon (Ctrl-C stops) offsync settings # open the Settings window offsync help # full CLI reference Pair with your phone: 1. Run `offsync start` 2. The tray icon's "Open settings…" reveals a QR code 3. Open the Offsync app on Android and scan it Docs: https://offsync.app Source: https://github.com/oshinpojta/offsync EOF