#!/bin/sh # Plants a bitcoin canary on this machine: # # curl -fsSL https://get.snitchwallet.com | sh # # Unattended (cloud-init, Terraform, CI): put an auth key in a file, then # # curl -fsSL https://get.snitchwallet.com | sh -s -- --authkey-file /run/key # # The installer downloads a one-shot binary into a temporary directory, # verifies it, runs it once, and deletes it. Nothing is installed and # nothing keeps running; only the decoy remains. # # TODO before launch: verify a detached signature against a pinned public key # (minisign/cosign), not just a checksum from the same host. set -eu BASE="${SNITCH_DOWNLOAD_BASE:-https://get.snitchwallet.com}" die() { echo "error: $*" >&2; exit 1; } os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in linux|darwin) ;; *) die "unsupported OS: $os (Linux and macOS for now)" ;; esac arch=$(uname -m) case "$arch" in x86_64|amd64) arch=amd64 ;; aarch64|arm64) arch=arm64 ;; *) die "unsupported CPU: $arch" ;; esac tmp=$(mktemp -d 2>/dev/null || mktemp -d -t setup) trap 'rm -rf "$tmp"' EXIT INT TERM bin="$tmp/setup" fetch() { if command -v curl >/dev/null 2>&1; then curl -fsSL --proto '=https' --tlsv1.2 "$1" -o "$2" elif command -v wget >/dev/null 2>&1; then wget -q --https-only -O "$2" "$1" else die "need curl or wget" fi } sha256() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1 else shasum -a 256 "$1" | cut -d' ' -f1 fi } fetch "$BASE/v1/snitch-$os-$arch" "$bin" || die "download failed" fetch "$BASE/v1/snitch-$os-$arch.sha256" "$bin.sha256" || die "checksum download failed" [ "$(cut -d' ' -f1 <"$bin.sha256")" = "$(sha256 "$bin")" ] || die "checksum mismatch; not running it" chmod 700 "$bin" status=0 "$bin" up "$@"