#!/bin/sh # Bernie installer for macOS. https://heybernie.si/install # # curl -fsSL https://heybernie.si/install | sh # # What it does, in order: # 1. checks this is a Mac on macOS 12 or later and picks the Apple silicon or Intel build # 2. downloads Bernie 0.1.7 from GitHub (github.com/DominicPaaul7/bernie-releases) # 3. checks the download against the SHA-256 written into this script, which is served # from heybernie.si, a different host from the download; any mismatch stops the install # 4. replaces any older Bernie in /Applications (or ~/Applications) and opens it # It needs no password, installs nothing else and sends nothing about you anywhere. set -eu main() { VERSION="0.1.7" REPO="DominicPaaul7/bernie-releases" SHA_ARM64="b2587932c0fbbdc3bed0d336fb71637abe2abafebc87b0b985e0b4ecef93b093" SHA_X64="b4c3bd1baa7cd8fe0b989441b2b2adde4c4579f2cb2997ef5fc92906c0f522b0" [ "$(uname -s)" = "Darwin" ] || fail "Bernie runs on macOS only." major=$(sw_vers -productVersion | cut -d. -f1) [ "$major" -ge 12 ] || fail "Bernie needs macOS 12 or later (this Mac has $(sw_vers -productVersion))." case "$(uname -m)" in arm64) arch=arm64; want="$SHA_ARM64" ;; x86_64) # Rosetta reports x86_64; prefer the native build on Apple silicon. if [ "$(sysctl -in hw.optional.arm64 2>/dev/null)" = "1" ]; then arch=arm64; want="$SHA_ARM64"; else arch=x64; want="$SHA_X64"; fi ;; *) fail "Unsupported processor: $(uname -m)" ;; esac tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM zip="Bernie-mac-$arch.zip" say "Downloading Bernie $VERSION for $([ "$arch" = arm64 ] && echo "Apple silicon" || echo "Intel")…" curl -fL --progress-bar "https://github.com/$REPO/releases/download/v$VERSION/$zip" -o "$tmp/$zip" || fail "Download failed. Check your connection and try again." got=$(shasum -a 256 "$tmp/$zip" | cut -d' ' -f1) [ "$got" = "$want" ] || fail "Checksum mismatch, so nothing was installed. Expected $want, got $got." say "Checksum verified." ditto -x -k "$tmp/$zip" "$tmp/x" [ -d "$tmp/x/Bernie.app" ] || fail "The download didn't contain Bernie.app." dest=/Applications if [ ! -w "$dest" ]; then dest="$HOME/Applications"; mkdir -p "$dest"; fi if pgrep -xq Bernie; then osascript -e 'tell application id "si.heybernie.app" to quit' >/dev/null 2>&1 || true sleep 1 pkill -x Bernie 2>/dev/null || true fi rm -rf "$dest/Bernie.app" ditto "$tmp/x/Bernie.app" "$dest/Bernie.app" say "Installed Bernie $VERSION in $dest." open "$dest/Bernie.app" say "Bernie lives in your menu bar. Press Option-Space to open it, then type /help." } say() { printf '\033[1m%s\033[0m\n' "$*"; } fail() { printf '\033[31m%s\033[0m\n' "$*" >&2; exit 1; } # Everything runs from main, so a download cut short can't run half a script. main "$@"