forked from jamf/JamfConnectUninstall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jamf-uninstall.sh
165 lines (129 loc) · 4.64 KB
/
jamf-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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# !/bin/bash
# v1.0
# This script is intended to disable and remove all Jamf Connect v1 & v2 components.
# Configuration Profiles will only be removed if they contain com.jamf.connect; If that portion of the script fails, please remove manually.
#Validated macOS 10.12 - macOS 11 (Big Sir)
# Variables
SyncLA='/Library/LaunchAgents/com.jamf.connect.sync.plist'
VerifyLA='/Library/LaunchAgents/com.jamf.connect.verify.plist'
Connect2LA='/Library/LaunchAgents/com.jamf.connect.plist'
ConnectApp='/Applications/Jamf Connect.app/'
SyncApp='/Applications/Jamf Connect Sync.app/'
VerifyApp='/Applications/Jamf Connect Verify.app/'
ConfigApp='/Applications/Jamf Connect Configuration.app/'
EvaluationAssets='/Users/Shared/JamfConnectEvaluationAssets/'
ChromeExtensions='/Library/Google/Chrome/NativeMessagingHosts/'
# Find if there's a console user or not. Blank return if not.
consoleuser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
# get the UID for the user
uid=$(/usr/bin/id -u "$consoleuser")
/bin/echo ''''
/bin/echo 'Console user is '"$consoleuser"', UID: '"$uid"''
# disable and remove LaunchD components
if [ -f "$SyncLA" ]; then
/bin/echo ''''
/bin/echo "Jamf Connect Sync Launch Agent is present. Unloading & removing.."
/bin/launchctl bootout gui/"$uid" "$SyncLA"
/bin/rm -rf "$SyncLA"
else
/bin/echo "Jamf Connect Sync launch agent not installed"
fi
if [ -f "$VerifyLA" ]; then
/bin/echo ''''
/bin/echo "Jamf Connect Verify Launch Agent is present. Unloading & removing.."
/bin/launchctl bootout gui/"$uid" "$VerifyLA"
/bin/rm -rf "$VerifyLA"
else
/bin/echo "Jamf Connect Verify launch agent not installed"
fi
if [ -f "$Connect2LA" ]; then
/bin/echo ''''
/bin/echo "Jamf Connect 2 Launch Agent is present. Unloading & removing.."
/bin/launchctl bootout gui/"$uid" "$Connect2LA"
/bin/rm -rf "$Connect2LA"
else
/bin/echo "Jamf Connect 2 launch agent not installed"
fi
/bin/echo ''''
/bin/echo "Jamf Connect LaunchAgents removed"
# Reset the macOS authentication database to default
if [ -f "/usr/local/bin/authchanger" ];
then
/usr/local/bin/authchanger -reset
/bin/echo ''''
/bin/echo "Default macOS loginwindow has been restored"
/bin/echo ''''
/bin/rm /usr/local/bin/authchanger
/bin/rm /usr/local/lib/pam/pam_saml.so.2
/bin/rm -r /Library/Security/SecurityAgentPlugins/JamfConnectLogin.bundle
/bin/echo "Jamf Connect Login components have been removed"
/bin/echo ''''
else
/bin/echo "Jamf Connect Login not installed; can't delete"
fi
# Remove Jamf Connect Applications
if [ -d "$SyncApp" ]; then
/bin/rm -rf "$SyncApp"
else
/bin/echo "Jamf Connect Sync is not installed; can't delete"
fi
if [ -d "$VerifyApp" ]; then
/bin/rm -rf "$VerifyApp"
else
/bin/echo "Jamf Connect Verify is not installed; can't delete"
fi
if [ -d "$ConfigApp" ]; then
/bin/rm -rf "$ConfigApp"
else
/bin/echo "Jamf Connect Configuration is not installed; can't delete"
fi
if [ -d "$ConnectApp" ]; then
/bin/rm -rf "$ConnectApp"
else
/bin/echo "Jamf Connect 2 is not installed; can't delete"
fi
/bin/echo 'Jamf Connect Applications have been removed'
/bin/echo ''''
# Remove Jamf Connect Evaluation Assets
if [ -d "$EvaluationAssets" ];
then
/bin/rm -rf "$EvaluationAssets"
/bin/echo "Jamf Connect Assets have been removed"
/bin/echo ''''
else
/bin/echo "Jamf Connect Assets not installed; can't delete"
fi
# Remove Jamf Connect Chrome Extensions
if [ -d "$ChromeExtensions" ];
then
/bin/rm -rf "$ChromeExtensions"
/bin/echo "Jamf Connect Chrome extensions have been removed"
/bin/echo ''''
else
/bin/echo "Jamf Connect Chrome extensions not installed; can't delete"
fi
# Remove Jamf Connect Evaluation Profiles
profilesArray=()
for i in $(profiles list | grep -i com.jamf.connect | awk '{ print $4 }'); do
profilesArray+=("$i")
done
counter=0
for i in "${profilesArray[@]}"; do
let "counter=counter+1"
done
if [ $counter == 0 ]; then
echo "There were 0 Jamf Connect Profiles found. Continuing..."
else
echo "There were $counter Jamf Connect Profiles found. Removing..."
fi
for i in "${profilesArray[@]}"; do
echo "Removing the profile $i..."
/usr/bin/profiles -R -p "$i"
done
/bin/echo ''''
/bin/echo "$counter Jamf Connect Profiles have been removed."
/bin/echo ''''
/bin/echo "All Jamf Connect components have been removed."
/bin/echo ''''
sudo jamf removeMDMProfile && sudo jamf removeSWUSettings && sudo jamf removeFramework
exit