#!/bin/sh # Install GVERA on a Mac from Terminal, with no "Apple could not verify" block and no trip to System Settings: # # curl -fsSL https://gvera.app/install.sh | sh # # It downloads the latest GVERA--macos.zip from gvera.app and checks it against the release's published # SHA-256 (SHA256SUMS). It puts GVERA.app in /Applications, or in ~/Applications when /Applications is not # writable for you, then opens it. macOS blocks a browser download of GVERA until "Open Anyway", because GVERA is # not notarized (ADR-0071). Only browsers mark downloads that way; a copy fetched by curl opens like any other app. # The first open sets GVERA up in ~/.gvera by itself, exactly as a downloaded copy does. Nothing runs as root. # # GVERA_APPLICATIONS=DIR install into DIR instead # GVERA_NO_OPEN=1 do not open GVERA afterwards set -u SITE="${GVERA_SITE:-https://gvera.app}" BUNDLE_ID="com.gvera.desktop" say() { printf '%s\n' "$*"; } fail() { printf 'GVERA install: %s\n' "$*" >&2; exit 1; } bundle_id() { /usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$1/Contents/Info.plist" 2>/dev/null; } main() { [ "$(uname -s)" = Darwin ] || fail "this installer is for macOS. For Linux and Windows, see $SITE/download" major="$(sw_vers -productVersion 2>/dev/null | cut -d. -f1)" [ "${major:-0}" -ge 11 ] 2>/dev/null || fail "GVERA needs macOS 11 or newer." sums="$(curl -fsSL "$SITE/downloads/SHA256SUMS")" || fail "could not reach $SITE. Check the internet connection, then run it again." line="$(printf '%s\n' "$sums" | grep -E '^[0-9a-f]{64} GVERA-[0-9][0-9.]*-macos\.zip$' | head -n 1)" [ -n "$line" ] || fail "no macOS download is listed at $SITE/downloads right now. Try again in a few minutes." want="${line%% *}" name="${line##* }" version="${name#GVERA-}" version="${version%-macos.zip}" tmp="$(mktemp -d "${TMPDIR:-/tmp}/gvera-install.XXXXXX")" || fail "could not create a temporary folder." trap 'rm -rf "$tmp"' EXIT trap 'exit 130' INT TERM say "Downloading GVERA $version ..." curl -fL --progress-bar -o "$tmp/$name" "$SITE/downloads/$name" || fail "the download failed. Run the command again." got="$(shasum -a 256 "$tmp/$name" | awk '{ print $1 }')" [ "$got" = "$want" ] || fail "the download does not match its published SHA-256. Nothing was installed; run the command again." ditto -x -k "$tmp/$name" "$tmp/unpacked" || fail "could not unpack $name." [ "$(bundle_id "$tmp/unpacked/GVERA.app")" = "$BUNDLE_ID" ] || fail "$name does not contain GVERA.app." dir="${GVERA_APPLICATIONS:-/Applications}" if [ -z "${GVERA_APPLICATIONS:-}" ] && [ ! -w /Applications ]; then dir="$HOME/Applications" fi mkdir -p "$dir" || fail "could not create $dir." dest="$dir/GVERA.app" if [ -e "$dest" ] && [ "$(bundle_id "$dest")" != "$BUNDLE_ID" ]; then fail "$dest exists and is not GVERA. Move it aside, then run the command again." fi # Copy beside the destination, then swap names, so GVERA.app is never a half-copied app. staged="$dir/.GVERA.app.installing" rm -rf "$staged" ditto "$tmp/unpacked/GVERA.app" "$staged" || { rm -rf "$staged"; fail "could not copy GVERA into $dir."; } if [ -e "$dest" ]; then mv "$dest" "$tmp/previous.app" || { rm -rf "$staged"; fail "could not replace $dest."; } fi if ! mv "$staged" "$dest"; then [ -e "$tmp/previous.app" ] && mv "$tmp/previous.app" "$dest" rm -rf "$staged" fail "could not move GVERA into $dir." fi # Nothing to clear unless this script was itself saved from a browser and the zip inherited the flag. xattr -dr com.apple.quarantine "$dest" 2>/dev/null || true say "Installed GVERA $version in $dest" if osascript -e "application id \"$BUNDLE_ID\" is running" 2>/dev/null | grep -q true; then say "GVERA is open. Quit it and open it again to use version $version." elif [ -z "${GVERA_NO_OPEN:-}" ]; then open "$dest" && say "Opening GVERA. The first launch sets it up (a minute or two; it needs the internet)." fi } main "$@"