forked from edingc/munki-enroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.sh
42 lines (31 loc) · 1.28 KB
/
client.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
#!/bin/sh
# Gather computer information
IDENTIFIER=$( defaults read /Library/Preferences/ManagedInstalls ClientIdentifier );
CATALOG=$( defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text1 );
AREA=$( defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text2 );
ROOM=$( defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text3 );
ASSET=$( defaults read /Library/Preferences/com.apple.RemoteDesktop.plist Text4 );
HOSTNAMETEMP=$( scutil --get ComputerName );
# Removes spaces if exists in hostname
HOSTNAME=${HOSTNAMETEMP// /}
# Change this URL to the location fo your Munki Enroll install
SUBMITURL="http://your.domain/deployment/enroll/server.php"
# Test the connection to the server
SHORTURL=$(echo "$SUBMITURL" | awk -F/ '{print $3}')
PINGTEST=$(ping -o "$SHORTURL" | grep "64 bytes")
if [ ! -z "$PINGTEST" ]; then
# Application paths
CURL="/usr/bin/curl"
$CURL --max-time 5 --silent --get \
-d catalog="$CATALOG" \
-d area="$AREA" \
-d room="$ROOM" \
-d asset="$ASSET" \
-d hostname="$HOSTNAME" \
"$SUBMITURL"
sudo defaults write /Library/Preferences/ManagedInstalls ClientIdentifier "$CATALOG/$AREA/$HOSTNAME"
exit 0
else
# No good connection to the server
exit 1
fi