#!/bin/zsh # Masterpeace Audio uninstaller - the only code that touches your files. # # What it does: moves Masterpeace Audio plugin files to your Trash (nothing is deleted, so Finder's "Put Back" # can restore them) and tells macOS to forget the matching installer receipts. # What it never does: delete anything, touch files that aren't listed below, use the network, or run anything else. # Every path it can touch is written out in full below. There are no wildcards. # # uninstall.sh list installed plugins, one key per line # uninstall.sh show [--data] ... the files that would be moved, one per line (changes nothing) # uninstall.sh run [--data] ... move them to /.Trash and forget the receipts (needs admin) # # is the signed-in user's home folder (e.g. /Users/alex). --data also moves licence keys and saved presets; # without it they stay so a reinstall needs no re-activation. # Keys: alive golddust 90sbox hueston magnacore subforce set -u export PATH=/usr/bin:/bin:/usr/sbin:/sbin # plugin files (system-wide installs from our .pkg, plus per-user copies if someone installed by hand) plugin_files() { local H=$1 case $2 in alive) print -l \ "/Library/Audio/Plug-Ins/Components/ALIVE.component" \ "/Library/Audio/Plug-Ins/VST3/ALIVE.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/ALIVE.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/ALIVE.component" \ "$H/Library/Audio/Plug-Ins/VST3/ALIVE.vst3" ;; golddust) print -l \ "/Library/Audio/Plug-Ins/Components/2K Gold Dust.component" \ "/Library/Audio/Plug-Ins/VST3/2K Gold Dust.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/2K Gold Dust.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/2K Gold Dust.component" \ "$H/Library/Audio/Plug-Ins/VST3/2K Gold Dust.vst3" ;; 90sbox) print -l \ "/Library/Audio/Plug-Ins/Components/The 90s Box.component" \ "/Library/Audio/Plug-Ins/VST3/The 90s Box.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/The 90s Box.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/The 90s Box.component" \ "$H/Library/Audio/Plug-Ins/VST3/The 90s Box.vst3" ;; hueston) print -l \ "/Library/Audio/Plug-Ins/Components/Hueston 948.component" \ "/Library/Audio/Plug-Ins/VST3/Hueston 948.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/Hueston 948.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/Hueston 948.component" \ "$H/Library/Audio/Plug-Ins/VST3/Hueston 948.vst3" ;; magnacore) print -l \ "/Library/Audio/Plug-Ins/Components/Magnacore Vocal Transformer.component" \ "/Library/Audio/Plug-Ins/VST3/Magnacore Vocal Transformer.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/Magnacore Vocal Transformer.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/Magnacore Vocal Transformer.component" \ "$H/Library/Audio/Plug-Ins/VST3/Magnacore Vocal Transformer.vst3" ;; subforce) print -l \ "/Library/Audio/Plug-Ins/Components/SUBFORCE.component" \ "/Library/Audio/Plug-Ins/VST3/SUBFORCE.vst3" \ "/Library/Application Support/Avid/Audio/Plug-Ins/SUBFORCE.aaxplugin" \ "$H/Library/Audio/Plug-Ins/Components/SUBFORCE.component" \ "$H/Library/Audio/Plug-Ins/VST3/SUBFORCE.vst3" ;; esac } # licence keys and saved presets (only with --data) user_data() { local H=$1 case $2 in alive) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/alive.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/alive.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/alive.mpkey" \ "$H/Library/Masterpeace Audio/ALIVE" ;; golddust) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/2k-gold-dust.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/2k-gold-dust.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/2k-gold-dust.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/2K Gold Dust" ;; 90sbox) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/the-90s-box.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/the-90s-box.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/the-90s-box.mpkey" ;; hueston) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/hueston-948.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/hueston-948.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/hueston-948.mpkey" \ "$H/Library/Audio/Presets/Masterpeace Audio/Hueston 948" ;; magnacore) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/magnacore.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/magnacore.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/magnacore.mpkey" ;; subforce) print -l \ "$H/Library/Application Support/Masterpeace Audio/Licenses/subforce.mpkey" \ "$H/Library/Application Support/Masterpeace Audio/Licenses/subforce.mpkey.old" \ "/Library/Application Support/Masterpeace Audio/Licenses/subforce.mpkey" ;; esac } receipts() { case $1 in alive) print -l audio.masterpeace.alive.au audio.masterpeace.alive.vst3 audio.masterpeace.alive.aax ;; golddust) print -l audio.masterpeace.golddust.au audio.masterpeace.golddust.vst3 audio.masterpeace.golddust.aax ;; 90sbox) print -l audio.masterpeace.the90sbox.au audio.masterpeace.the90sbox.vst3 audio.masterpeace.the90sbox.aax ;; hueston) print -l audio.masterpeace.hueston948.au audio.masterpeace.hueston948.vst3 audio.masterpeace.hueston948.aax ;; magnacore) print -l audio.masterpeace.magnacore.au audio.masterpeace.magnacore.vst3 audio.masterpeace.magnacore.aax ;; subforce) print -l audio.masterpeace.subforce.au audio.masterpeace.subforce.vst3 audio.masterpeace.subforce.aax ;; esac } KEYS=(alive golddust 90sbox hueston magnacore subforce) die() { print -u2 "uninstall: $1"; exit 2; } # the home folder must be a real user's folder: /Users/, existing, not a symlink check_home() { [[ $1 =~ '^/Users/[A-Za-z0-9_][A-Za-z0-9._-]*$' && -d $1 && ! -L $1 ]] || die "not a user home folder: $1" } # files that exist for these keys (plugin files always, user data only with --data) targets() { local H=$1 data=$2; shift 2 local k f for k in "$@"; do (( ${KEYS[(Ie)$k]} )) || die "unknown plugin: $k" { plugin_files $H $k; (( data )) && user_data $H $k; } | while IFS= read -r f; do [[ -e $f || -L $f ]] && print -r -- $f done done } cmd=${1:-}; (( $# )) && shift H=${1:-}; (( $# )) && shift; check_home $H case $cmd in list) for k in $KEYS; do [[ -n $(targets $H 0 $k) ]] && print $k done ;; show|run) data=0; [[ ${1:-} == --data ]] && { data=1; shift; } (( $# )) || die "no plugins chosen" for k in "$@"; do (( ${KEYS[(Ie)$k]} )) || die "unknown plugin: $k"; done files=("${(@f)$(targets $H $data "$@")}"); files=(${files:#}) if [[ $cmd == show ]]; then (( $#files )) && print -rl -- $files; exit 0; fi [[ $EUID == 0 ]] || die "run needs admin rights" owner=$(stat -f %Su $H) || die "can't read the owner of $H" trash="$H/.Trash"; [[ -d $trash && ! -L $trash ]] || { mkdir -m 700 $trash && chown $owner $trash; } || die "no Trash folder" stamp=$(date +%Y-%m-%d\ %H.%M.%S) failed=0 for f in $files; do dest="$trash/${f:t}" [[ -e $dest || -L $dest ]] && dest="$trash/${f:t:r} (removed $stamp)${${f:t:e}:+.${f:t:e}}" if mv -n -- $f $dest && [[ ! -e $f && ! -L $f ]] && chown -R -h $owner $dest; then print -r -- "moved to Trash: $f" else print -r -- "could not move: $f"; failed=1; fi done for k in "$@"; do receipts $k | while IFS= read -r r; do pkgutil --pkg-info $r >/dev/null 2>&1 && pkgutil --forget $r >/dev/null && print "forgot installer receipt: $r" done done # tidy our own folders only when they are now empty (rmdir never removes a folder that still has files) for d in "$H/Library/Application Support/Masterpeace Audio/Licenses" "$H/Library/Application Support/Masterpeace Audio" \ "$H/Library/Masterpeace Audio" "$H/Library/Audio/Presets/Masterpeace Audio" \ "/Library/Application Support/Masterpeace Audio/Licenses" "/Library/Application Support/Masterpeace Audio"; do [[ -d $d && ! -L $d ]] && rmdir -- $d 2>/dev/null && print -r -- "removed empty folder: $d" done exit $failed ;; *) die "usage: uninstall.sh list | show [--data] ... | run [--data] ..." ;; esac