I'm trying to get this script to run on a schedule of some sort as a launch agent. It keeps failing as an exit code 1. Hopefully someone knows what I'm doing wrong.
#!/bin/bash
# Logfile
LOGFILE="/Library/Logs/ClientEnroll.log"
#Get the MAC Address of the machine
MAC=$( networksetup -getmacaddress en0 | awk '{ print $3 }' | sed 's/:/./g' )
echo "$MAC" >> $LOGFILE
#Gather information from the JSS
JSSGroups=$( curl -s -u svc_account:password https://jss.mydomain.com:8443/JSSResource/computers/macaddress/$MAC
| xpath //computer/groups_accounts/computer_group_memberships[1]
| sed -e 's/<computer_group_memberships>//g;s/</computer_group_memberships>//g;s/<group>//g;s/</group>/
/g' )
#Show the groups the machine belongs to
echo "$JSSGroups"
#Check if the machine is enrolled in the JSS and enroll if needed
CheckMachine=`echo "$JSSGroups" | grep "All Managed Clients"`
if [ "$CheckMachine" != "" ]; then
echo "Machine is enrolled" >> $LOGFILE
else
echo "Machine is not enrolled...running QuickAdd.pkg" >> $LOGFILE
/usr/sbin/installer -pkg /Library/Enroll/QuickAdd.pkg -target / >> $LOGFILE
fi