From 43e77dd3098a7911de25f9f9e56ba5fe153115f7 Mon Sep 17 00:00:00 2001 From: Nindi Gill Date: Sun, 7 Aug 2022 14:23:06 +1000 Subject: [PATCH] Add uninstall script to repo --- Scripts/uninstall.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 Scripts/uninstall.sh diff --git a/Scripts/uninstall.sh b/Scripts/uninstall.sh new file mode 100755 index 0000000..dda3dbd --- /dev/null +++ b/Scripts/uninstall.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -e + +identifier="com.ninxsoft.mist.helper" +files=( + "/Applications/Mist.app" + "/Library/LaunchDaemons/$identifier.plist" + "/Library/PrivilegedHelperTools/$identifier" +) +did_something="" + +# check for escalated privileges +if [[ ! "$EUID" == 0 ]] ; then + echo "This script needs to be run as root! Exiting..." + exit 0 +fi + +# unload privileged helper tool +if launchctl print "system/$identifier" &> /dev/null ; then + echo "Unloading Privileged Helper Tool..." + launchctl bootout "system/$identifier" + did_something="Yes" +fi + +# remove files +for file in "${files[@]}" ; do + + if [[ -e "$file" ]] ; then + echo "Removing '$file'..." + fi + + if [[ -f "$file" ]] ; then + rm "$file" + did_something="Yes" + fi + + if [[ -d "$file" ]] ; then + rm -r "$file" + did_something="Yes" + fi +done + +if [[ -n "$did_something" ]] ; then + echo "Done!" +else + echo "Nothing to do!" +fi + +exit 0