#!/bin/sh # Installs Diskwise (https://diskwise.app) and opens it. In Terminal: # # curl -fsSL https://diskwise.app/install.sh | sh # # What it does: # 1. Checks that this Mac can run Diskwise: Apple silicon and macOS 15 or later. # 2. Downloads the same disk image as the Download button on diskwise.app, into a temporary folder. # 3. Opens the disk image out of sight, checks that the app is signed with Diskwise's own certificate, and # copies Diskwise into Applications (your own Applications folder if you can't write to the main one). # 4. Closes the disk image, deletes the temporary folder and opens Diskwise. # # It needs no password and changes nothing else on your Mac. Run it again to update. A download made with # curl isn't marked as coming from a browser, so macOS doesn't ask you to confirm Diskwise in System Settings. # To remove Diskwise, drag it from Applications to the Trash. # Everything is inside main, so a download cut short runs nothing main() { set -eu url="https://diskwise.app/Diskwise.dmg" name="Diskwise" # The app's own designated requirement: its bundle ID, signed with the "Diskwise Local" certificate (its SHA-1) signer='=identifier "app.diskwise.Diskwise" and certificate leaf = H"55a0fea03fabd7cdebd42174a9e5c8e461c219d1"' [ "$(uname -s)" = Darwin ] || stop "Diskwise is a Mac app, and this computer isn't a Mac." # hw.optional.arm64 is 1 on Apple silicon, even in a Terminal running under Rosetta [ "$(sysctl -in hw.optional.arm64)" = 1 ] || stop "Diskwise needs a Mac with Apple silicon (M1 or newer)." macos=$(sw_vers -productVersion) [ "${macos%%.*}" -ge 15 ] || stop "Diskwise needs macOS 15 or later, and this Mac has macOS $macos." if pgrep -xq "$name"; then stop "Diskwise is open. Quit it from its menu bar icon, then run this again." fi apps=/Applications [ -w "$apps" ] || apps="$HOME/Applications" tmp=$(mktemp -d "${TMPDIR:-/tmp}/diskwise.XXXXXX") volume="$tmp/volume" trap 'cleanup' EXIT trap 'exit 1' HUP INT TERM say "Downloading Diskwise" curl -fL --progress-bar -o "$tmp/$name.dmg" "$url" || stop "the download didn't finish. Check your connection and try again." mkdir "$volume" hdiutil attach -quiet -nobrowse -readonly -noautoopen -mountpoint "$volume" "$tmp/$name.dmg" /dev/null || stop "the app isn't signed by Diskwise, so nothing was copied. Try again, or write to support@diskwise.app." say "Copying Diskwise into $apps" mkdir -p "$apps" rm -rf "$apps/$name.app" 2>/dev/null || stop "the copy of Diskwise already in $apps couldn't be replaced. Drag it to the Trash, then run this again." ditto "$volume/$name.app" "$apps/$name.app" || stop "Diskwise couldn't be copied into $apps." say "Diskwise is installed. Opening it now." open "$apps/$name.app" } say() { printf '%s\n' "$*"; } # Closes the disk image, by force if Spotlight is still looking at it, and deletes the temporary folder cleanup() { if [ -d "$volume" ]; then hdiutil detach -quiet "$volume" >/dev/null 2>&1 || hdiutil detach -quiet -force "$volume" >/dev/null 2>&1 || true fi rm -rf "$tmp" } stop() { printf 'Diskwise was not installed: %s\n' "$*" >&2 exit 1 } main "$@"