-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexta_CI_JSSID.sh
executable file
·76 lines (73 loc) · 2.29 KB
/
exta_CI_JSSID.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
#!/bin/sh
# CI - JSSID
#
# Updated Oct 19th 2015
# Updated By Andrew Seago
#
# set -x # DEBUG. Display commands and their arguments as they are executed
# set -v # VERBOSE. Display shell input lines as they are read.
# set -n # EVALUATE. Check syntax of the script but dont execute
## Variables
####################################################################################################
extaPLIST="/var/gne/extas.plist"
extaCAT="CI"
extaNAME="JSSID"
logName="/Library/Logs/gInstall/extas.log"
jssAddress=`defaults read /Library/Preferences/com.jamfsoftware.jamf jss_url`
apiUsername=""
apiPassword=""
SystemUDID=`system_profiler SPHardwareDataType | grep 'Hardware UUID:' | awk '{print$3}'`
jssID=`curl -ks -u "$apiUsername":"$apiPassword" "$jssAddress"JSSResource/computers/udid/$SystemUDID/subset/General -X GET | xml sel -t -v "/computer/general/id"`
xml_download_url="$jssAddress/imaging/xmlstarlet.pkg"
function InstallXML () {
if [ ! -f /usr/local/bin/xml ];then
curl -o /var/tmp/xmlstarlet.pkg "$xml_download_url"
installer -pkg /var/tmp/xmlstarlet.pkg -target /
fi
}
function log () {
echo $1
echo $(date "+%Y-%m-%d %H\:%M:%S: ") $1 >> $logName
}
function wPlist () {
# wPlist "$extaCAT:$extaNAME" "$centrifyStatus" "$extaPLIST"
Key=$1
Value=$2
PlistLocation=$3
if [ "$Value" != "" ]; then
log "Writing $Key = $Value to $PlistLocation"
currentInfo=`/usr/libexec/PlistBuddy -c "Print :$Key" "$PlistLocation" 2>&1 /dev/null`
if [ "$currentInfo" = "" ]; then
/usr/libexec/PlistBuddy -c "Add :$Key string $Value" "$PlistLocation"
else
/usr/libexec/PlistBuddy -c "Delete :$Key" "$PlistLocation"
/usr/libexec/PlistBuddy -c "Add :$Key string $Value" "$PlistLocation"
fi
else
log "$Key does not have a Value"
fi
chmod 644 "$PlistLocation"
}
function getJSSid () {
if [ "$jssID" == "" ]; then
if [ -f /var/gne/.jssid ]; then
jssIDlog=`cat /var/gne/.jssid`
if [ "$jssIDlog" = "" ]; then
result="N/A"
else
result="$jssIDlog"
fi
fi
else
result="$jssID"
echo "$jssID" > /var/gne/.jssid
fi
wPlist "$extaCAT:$extaNAME" "$result" "$extaPLIST"
wPlist "$extaCAT:jssAddress" "$jssAddress" "$extaPLIST"
echo "<result>$result</result>"
}
## Script
####################################################################################################
InstallXML
getJSSid
exit 0