Mist/Scripts/uninstall.sh

51 lines
915 B
Bash
Raw Normal View History

2022-08-07 00:23:06 -04:00
#!/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
2022-12-09 20:59:12 -05:00
rm -rf "$file"
2022-08-07 00:23:06 -04:00
did_something="Yes"
fi
done
if [[ -n "$did_something" ]] ; then
echo "Done!"
else
echo "Nothing to do!"
fi
exit 0