Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pythoninthegrass/fe646e91e01b96424bed60c8a1218dfe to your computer and use it in GitHub Desktop.
Save pythoninthegrass/fe646e91e01b96424bed60c8a1218dfe to your computer and use it in GitHub Desktop.
#!/bin/bash
########################################################################
# Originally Created Created By: Andrina Kelly, [email protected]
# Modifications from scripts from Bryson Tyrrell
# Final by Ross Derewianko
# Creation Date: April 2015
# Last modified: April, 18 2015
# Brief Description: Gather diagnostic logs and submit to the JSS
########################################################################
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "Basic_auth"
#base 64 encoded username:password
if [ "$4" != "" ] && [ "$basic_auth" == "" ]; then
basic_auth=$4
fi
FILE=`ls -ltr /var/tmp | tail -1 | awk '{print $9}'`
jss=`defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url`
serial=`/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial Number/ {print $NF}'`
#find the machines ID
fullmachineinfo=$(curl "$jss"JSSResource/computers/serialnumber/"$serial" -H "Authorization: Basic $basic_auth")
machineid=$(echo $fullmachineinfo | /usr/bin/awk -F'<id>|</id>' '{print $2}'| sed 's/ /+/g')
#used for debugging
#echo $machineid
expect <<- DONE
set timeout -1
spawn sysdiagnose
# Look for prompt
expect "*?ontinue*"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof
DONE
fileupload$(curl -X "POST" "$jss"JSSResource/fileuploads/computers/id/$machineid -F "file=@"/var/tmp/$FILE""\
-H "Authorization: Basic $basic_auth")
#used for debugigng
#echo $fileupload
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment