#!/bin/bash # OfficeParty 0.8.0. Download and inspect this script before running it. set -euo pipefail version='0.8.0' url='https://party.closedai.in/downloads/0.8.0/OfficeParty-0.8.0-arm64.zip' expected_sha256='3c6a31b6bace527b66a9aa9c5a03b387b5f58f362b30676ce41d14a9767bca9f' appdir="$HOME/Applications" replace=false fail() { printf 'OfficeParty: %s\n' "$*" >&2; exit 1; } while [ "$#" -gt 0 ]; do case "$1" in --appdir) [ "$#" -ge 2 ] || fail '--appdir needs a directory'; appdir="$2"; shift 2 ;; --replace) replace=true; shift ;; --help) printf 'Usage: bash install.sh [--appdir /Applications] [--replace]\nDefault: ~/Applications. Close OfficeParty before updating.\n'; exit 0 ;; *) fail "Unknown option: $1" ;; esac done [ "$(uname -s)" = Darwin ] || fail 'Requires macOS.' [ "$(uname -m)" = arm64 ] || fail 'Requires Apple Silicon; run from a native terminal, not Rosetta.' os_version=$(sw_vers -productVersion) IFS=. read -r major minor patch <<< "$os_version" [ "$major" -gt 14 ] || { [ "$major" -eq 14 ] && [ "${minor:-0}" -ge 4 ]; } || fail 'Requires macOS 14.4 or newer.' pgrep -x OfficeParty >/dev/null && fail 'Quit OfficeParty before installing.' mkdir -p "$appdir" appdir=$(cd "$appdir" && pwd -P) target="$appdir/OfficeParty.app" backup="$appdir/.OfficeParty.previous.app" if [ -e "$target" ] || [ -L "$target" ]; then [ ! -L "$target" ] || fail 'Refusing to replace a symbolic link.' [ "$replace" = true ] || fail 'Already installed. Run again with --replace to update.' [ "$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$target/Contents/Info.plist")" = com.officeparty.app ] || fail 'Existing app has an unexpected identity.' [ ! -e "$backup" ] && [ ! -L "$backup" ] || fail "Previous backup exists at $backup. Move it aside before updating again." fi work=$(mktemp -d "$appdir/.officeparty-install.XXXXXX") trap 'rm -rf "$work"' EXIT curl --fail --location --proto '=https' --proto-redir '=https' --tlsv1.2 --retry 3 --connect-timeout 15 --max-time 600 "$url" -o "$work/release.zip" actual_sha256=$(shasum -a 256 "$work/release.zip" | awk '{print $1}') [ "$actual_sha256" = "$expected_sha256" ] || fail 'Download checksum mismatch; nothing installed.' ditto -x -k "$work/release.zip" "$work/unpacked" app="$work/unpacked/OfficeParty.app" [ -d "$app" ] && [ ! -L "$app" ] || fail 'Archive does not contain OfficeParty.app.' plist="$app/Contents/Info.plist" [ "$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$plist")" = com.officeparty.app ] || fail 'Unexpected app identity.' [ "$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$plist")" = "$version" ] || fail 'Unexpected app version.' codesign --verify --deep --strict "$app" [ "$(lipo -archs "$app/Contents/MacOS/OfficeParty")" = arm64 ] || fail 'Unexpected app architecture.' # Preserve normal Gatekeeper checks for an Internet download. Never remove quarantine. xattr -w com.apple.quarantine "0083;$(printf '%x' "$(date +%s)");OfficeParty Installer;" "$app" if [ -e "$target" ]; then mv "$target" "$backup"; fi if ! mv "$app" "$target"; then if [ -e "$backup" ] && [ ! -e "$target" ]; then mv "$backup" "$target"; fi fail 'Installation failed; restored the previous app when available.' fi printf 'Installed OfficeParty %s at %s\n' "$version" "$target" printf 'Open it from Finder. This preview is not notarized; macOS may require approval in System Settings > Privacy & Security.\n' if [ -e "$backup" ]; then printf 'Previous version retained at %s\n' "$backup"; fi