#!/bin/sh # Panegrip relay installer: curl -fsSL https://get.panegrip.dev | sh # # Downloads panegrip-relay for this machine, checks its SHA-256, installs it # to ~/.local/bin (PANEGRIP_BIN_DIR to change), starts it as a background # service and shows a QR code to scan with Panegrip on your iPhone. # PANEGRIP_NO_SERVICE=1 install the binary only # PANEGRIP_NO_PAIR=1 skip the QR code (for scripted installs) set -eu BASE="${PANEGRIP_BASE_URL:-https://get.panegrip.dev}" say() { printf '%s\n' "$*"; } fail() { printf 'panegrip: %s\n' "$*" >&2; exit 1; } case "$(uname -s)" in Darwin) os=macos ;; Linux) os=linux ;; *) fail "only macOS and Linux are supported" ;; esac case "$(uname -m)" in arm64|aarch64) arch=arm64 ;; x86_64|amd64) arch=x86_64 ;; *) fail "unsupported CPU: $(uname -m)" ;; esac command -v curl >/dev/null 2>&1 || fail "curl is required" version="$(curl -fsSL "$BASE/latest")" || fail "cannot reach $BASE" name="panegrip-relay-$os-$arch" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT say "Downloading panegrip-relay ${version} for ${os}/${arch}..." curl -fsSL "$BASE/releases/$version/$name.tar.gz" -o "$tmp/$name.tar.gz" || fail "download failed" curl -fsSL "$BASE/releases/$version/SHA256SUMS" -o "$tmp/SHA256SUMS" || fail "checksum download failed" expected="$(grep " $name.tar.gz\$" "$tmp/SHA256SUMS" | cut -d' ' -f1)" if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "$tmp/$name.tar.gz" | cut -d' ' -f1)" else actual="$(shasum -a 256 "$tmp/$name.tar.gz" | cut -d' ' -f1)" fi [ -n "$expected" ] && [ "$expected" = "$actual" ] || fail "checksum mismatch — not installing" tar -xzf "$tmp/$name.tar.gz" -C "$tmp" dest="${PANEGRIP_BIN_DIR:-$HOME/.local/bin}" mkdir -p "$dest" install -m 0755 "$tmp/panegrip-relay" "$dest/panegrip-relay" say "Installed $dest/panegrip-relay" case ":$PATH:" in *":$dest:"*) ;; *) say "Add $dest to your PATH to run panegrip-relay directly." ;; esac command -v herdr >/dev/null 2>&1 || say "Note: Herdr was not found on PATH — install it from https://herdr.dev" [ "${PANEGRIP_NO_SERVICE:-}" = 1 ] && exit 0 "$dest/panegrip-relay" install-service [ "${PANEGRIP_NO_PAIR:-}" = 1 ] && exit 0 i=0 until "$dest/panegrip-relay" status 2>/dev/null | grep -q "running ("; do i=$((i + 1)); [ "$i" -gt 30 ] && fail "the relay did not start; see ~/Library/Logs/panegrip-relay.log or journalctl --user -u panegrip-relay" sleep 1 done sleep 2 "$dest/panegrip-relay" pair --wait