#!/usr/bin/env bash # Voiceinator installer. Read it, then run it: # curl -fsSL https://voiceinator.com/install.sh | bash # Free, Apple Silicon only, macOS 14+. Installs to /Applications. set -euo pipefail # The publish step updates these two lines. VERSION="1.0.0" SHA256="bf66fe87793acec8995c845933ce640bcdf6153cdb10bb9155cedd59a4c5feea" URL="${VOICEINATOR_DMG_URL:-https://updates.boringlabs.online/Voiceinator-$VERSION.dmg}" INSTALL_DIR="${INSTALL_DIR:-/Applications}" die() { echo "Voiceinator: $*" >&2; exit 1; } [ "$(uname -s)" = "Darwin" ] || die "this is a Mac app." [ "$(uname -m)" = "arm64" ] || die "needs an Apple Silicon Mac (M1 or newer). Intel Macs can't run it." [ "$(sw_vers -productVersion | cut -d. -f1)" -ge 14 ] || die "needs macOS 14 or later." [ -w "$INSTALL_DIR" ] || die "$INSTALL_DIR isn't writable by you. Ask an admin, or set INSTALL_DIR to a folder you own." # The DMG is ~4.4 GB and the app is ~4.9 GB, and both exist at once. NEED_GB="${VOICEINATOR_NEED_GB:-10}" free_gb=$(( $(df -k "$INSTALL_DIR" | awk 'NR==2 {print $4}') / 1048576 )) [ "$free_gb" -ge "$NEED_GB" ] || die "needs about $NEED_GB GB free, you have $free_gb GB. Clear some space and run it again." TMP="$(mktemp -d)" MNT="$TMP/mnt" cleanup() { hdiutil detach "$MNT" -quiet 2>/dev/null || true rm -rf "$TMP" } trap cleanup EXIT echo "1/3 Downloading Voiceinator $VERSION (about 4.4 GB, it works offline)..." curl -fL --progress-bar "$URL" -o "$TMP/Voiceinator.dmg" echo "2/3 Checking the download..." actual="$(shasum -a 256 "$TMP/Voiceinator.dmg" | cut -d' ' -f1)" [ "$actual" = "$SHA256" ] || die "checksum mismatch, so I stopped. Expected $SHA256, got $actual." echo "3/3 Installing to $INSTALL_DIR..." mkdir -p "$MNT" hdiutil attach -nobrowse -readonly -quiet -mountpoint "$MNT" "$TMP/Voiceinator.dmg" [ -d "$MNT/Voiceinator.app" ] || die "Voiceinator.app isn't in the disk image." if pgrep -x Voiceinator >/dev/null 2>&1; then osascript -e 'tell application "Voiceinator" to quit' >/dev/null 2>&1 || true sleep 2 fi rm -rf "$INSTALL_DIR/Voiceinator.app" ditto "$MNT/Voiceinator.app" "$INSTALL_DIR/Voiceinator.app" xattr -cr "$INSTALL_DIR/Voiceinator.app" echo "Done. Hold your key and talk." # Only open it for a real install, not a test dir. [ "$INSTALL_DIR" != "/Applications" ] || open "$INSTALL_DIR/Voiceinator.app"