#!/bin/sh set -- 'https://hosterman.dev/downloads/local/0.1.0-preview-88be3267b897/Hosterman-Local-preview.dmg' '784a5c1ccc771085bfa4abc35b9ffa5cadf61f7d6cf3bcaca3403a5d1744c47e' # The download endpoint supplies the disk image URL and its expected SHA-256. set -eu umask 077 [ "$(uname -s)" = Darwin ] || { echo 'Use the starter for your operating system.' >&2; exit 1; } url=${1:?Missing disk image URL} digest=${2:-} tmp=$(mktemp -d) mount="$tmp/disk" stage='' mounted=false cleanup() { if [ "$mounted" = true ]; then hdiutil detach "$mount" -quiet || return; fi [ -z "$stage" ] || rm -rf "$stage" rm -rf "$tmp" } trap cleanup EXIT trap 'exit 1' HUP INT TERM curl -fsSL "$url" -o "$tmp/Hosterman.dmg" if [ -n "$digest" ]; then printf '%s %s\n' "$digest" "$tmp/Hosterman.dmg" | shasum -a 256 -c - >/dev/null else spctl --assess --type open --context context:primary-signature "$tmp/Hosterman.dmg" fi mkdir "$mount" hdiutil attach "$tmp/Hosterman.dmg" -readonly -nobrowse -mountpoint "$mount" -quiet mounted=true source="$mount/Hosterman Local.app" codesign --verify --deep --strict "$source" dest="$HOME/Applications/Hosterman Local.app" if [ -e '/Applications/Hosterman Local.app' ]; then dest='/Applications/Hosterman Local.app'; fi if [ ! -e "$dest" ]; then mkdir -p "$HOME/Applications" stage=$(mktemp -d "$HOME/Applications/.hosterman.XXXXXXXX") ditto "$source" "$stage/Hosterman Local.app" xattr -w com.apple.quarantine "0081;$(printf '%x' "$(date +%s)");Hosterman;" "$stage/Hosterman Local.app" mv -n "$stage/Hosterman Local.app" "$HOME/Applications/" fi if ! diff -qr "$source" "$dest" >/dev/null; then echo 'A different copy of Hosterman Local is installed. Open the downloaded disk image in Finder to review the replacement.' >&2 exit 1 fi open "$dest"