-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enterprise_Connect_Uninstall.sh
54 lines (45 loc) · 2.2 KB
/
Enterprise_Connect_Uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/zsh
# Unload the Kerberos helper from versions of EC prior to 1.6
if [[ -e /Library/LaunchDaemons/com.apple.Enterprise-Connect.kerbHelper.plist ]]; then
echo "Unloading Kerberos helper..."
launchctl bootout system /Library/LaunchDaemons/com.apple.Enterprise-Connect.kerbHelper.plist
rm /Library/LaunchDaemons/com.apple.Enterprise-Connect.kerbHelper.plist
fi
# Remove the privileged helper from versions of EC prior to 1.6
if [[ -e /Library/PrivilegedHelperTools/com.apple.Enterprise-Connect.kerbHelper ]]; then
echo "Removing privileged helper..."
rm /Library/PrivilegedHelperTools/com.apple.Enterprise-Connect.kerbHelper
fi
# Remove the authorization database entry from versions of EC prior to 1.6
if /usr/bin/security authorizationdb read com.apple.Enterprise-Connect.writeKDCs &>/dev/null; then
echo "Removing authorization database entry..."
/usr/bin/security authorizationdb remove com.apple.Enterprise-Connect.writeKDCs
fi
# Check if the launch agent exists for versions 2.0 or greater
if [[ -e /Library/LaunchAgents/com.abb.enterprise-connect.plist ]]; then
echo "Unloading Enterprise Connect LaunchAgent..."
# Get the logged-in user
loggedInUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
if [[ -n $loggedInUser ]]; then
loggedInUID=$(id -u "$loggedInUser")
# Unload the LaunchAgent for the logged-in user
launchctl bootout gui/$loggedInUID /Library/LaunchAgents/com.abb.enterprise-connect.plist
rm /Library/LaunchAgents/com.abb.enterprise-connect.plist
else
echo "No logged-in user found."
fi
# Quit the Enterprise Connect menu extra and app
echo "Stopping Enterprise Connect processes..."
# killall "Enterprise Connect Menu" &>/dev/null
# killall "Enterprise Connect" &>/dev/null
ps aux | grep "[E]nterprise Connect" | awk '{print $2}' | xargs kill -9
ps aux | grep "[E]nterprise Connect Menu" | awk '{print $2}' | xargs kill -9
fi
# Finally, remove the Enterprise Connect app bundle
if [[ -d "/Applications/Enterprise Connect.app" ]]; then
echo "Removing Enterprise Connect app..."
rm -rf "/Applications/Enterprise Connect.app/"
else
echo "Enterprise Connect app not found."
fi
echo "Cleanup completed."