#!/bin/sh # Browsentic for macOS, installed in one line: # # curl -fsSL https://browsentic.com/install.sh | sh # # Downloads the release disk image, checks its signature is intact, copies Browsentic.app into # Applications and opens it. The app does the rest from a window. Nothing here needs a password. # # BROWSENTIC_VERSION=0.6.0 install that release instead of the latest # BROWSENTIC_NO_OPEN=1 install without opening the app set -eu REPO="imshaikot/browsentic" say() { printf ' %s\n' "$*"; } die() { printf '\n browsentic: %s\n\n' "$*" >&2; exit 1; } [ "$(uname -s)" = "Darwin" ] || die "this installer is for macOS. Everywhere else: npx browsentic setup" major="$(sw_vers -productVersion | cut -d. -f1)" [ "$major" -ge 14 ] || die "the app needs macOS 14 or newer, and this is $(sw_vers -productVersion). Use: npx browsentic setup" version="${BROWSENTIC_VERSION:-}" if [ -z "$version" ]; then latest="$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/$REPO/releases/latest")" \ || die "could not reach github.com to find the latest release. Check the connection and run this again." version="${latest##*/v}" fi case "$version" in [0-9]*.[0-9]*.[0-9]*) ;; *) die "could not work out the latest version (got \"$version\"). Set BROWSENTIC_VERSION=x.y.z and run this again." ;; esac work="$(mktemp -d)" mount="$work/volume" cleanup() { hdiutil detach "$mount" -quiet 2>/dev/null || true rm -rf "$work" } trap cleanup EXIT INT TERM printf '\n Browsentic %s\n\n' "$version" say "Downloading" curl -fL --progress-bar -o "$work/Browsentic.dmg" \ "https://github.com/$REPO/releases/download/v$version/Browsentic-$version.dmg" \ || die "release v$version carries no macOS app. See https://github.com/$REPO/releases" mkdir "$mount" hdiutil attach "$work/Browsentic.dmg" -nobrowse -readonly -quiet -mountpoint "$mount" \ || die "the download would not open as a disk image. Run this again." [ -d "$mount/Browsentic.app" ] || die "the disk image holds no Browsentic.app." codesign --verify --deep "$mount/Browsentic.app" 2>/dev/null \ || die "the app's signature does not match its contents, so it was not installed." dest="/Applications" [ -w "$dest" ] || dest="$HOME/Applications" mkdir -p "$dest" if pgrep -xq Browsentic; then say "Closing the running app" osascript -e 'quit app "Browsentic"' >/dev/null 2>&1 || true sleep 1 pkill -x Browsentic 2>/dev/null || true fi say "Installing to $dest/Browsentic.app" rm -rf "$dest/Browsentic.app" ditto "$mount/Browsentic.app" "$dest/Browsentic.app" printf '\n Done.' if [ -z "${BROWSENTIC_NO_OPEN:-}" ]; then printf ' Opening Browsentic: press "Set up everything" and it installs the rest.\n\n' open "$dest/Browsentic.app" else printf ' Open Browsentic from Applications, and press "Set up everything".\n\n' fi