diff --git a/Assets/Uninstall.sh b/Assets/Uninstall.sh index 0b9d344..f708063 100755 --- a/Assets/Uninstall.sh +++ b/Assets/Uninstall.sh @@ -1,5 +1,12 @@ -current_user=$(ls -l /dev/console | awk '{print $3}') -console_user_uid=$(/usr/bin/id -u "$current_user") +#!/bin/sh +# Script requires root so check for root access +if [ $(id -u) -ne 0 ]; then + echo "Please run this script as root or using sudo" + exit 1 +fi +# Use Apple Recommended Method to detect the user signed in to the desktop +current_user=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }') +console_user_uid=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/kCGSSessionUserIDKey/ {print $NF; exit}' ) # Kill the process echo "Killing the process..." pkill -f SupportCompanion @@ -27,4 +34,4 @@ rm -rf "/Library/Application Support/SupportCompanion" echo "Forgetting the package..." pkgutil --forget com.almenscorner.supportcompanion > /dev/null 2>&1 pkgutil --forget com.almenscorner.supportcompanion.LaunchAgent > /dev/null 2>&1 -pkgutil --forget com.almenscorner.supportcompanion.suite > /dev/null 2>&1 \ No newline at end of file +pkgutil --forget com.almenscorner.supportcompanion.suite > /dev/null 2>&1