Skip to content

Commit

Permalink
Merge pull request #50 from pboushy/add-check-for-root
Browse files Browse the repository at this point in the history
Add check for root and use Apple best practice
  • Loading branch information
almenscorner authored Nov 6, 2024
2 parents 60c751f + b87b980 commit 361f65d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Assets/Uninstall.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
pkgutil --forget com.almenscorner.supportcompanion.suite > /dev/null 2>&1

0 comments on commit 361f65d

Please sign in to comment.