Hi,
What i'm trying to do is to run a query in our firstrun script, on the JSS for the Mac it's currently running on. All it's trying to do is to see if the department and building settings are correctly configured. (Our JSS occasionally doesn't configure these fields properly via prestage imaging.) If they are, it skips a section of code that would give a menu choice. Here's what i've got so far (in a highly simplified version):
#!/bin/bash
JSSUSR="x"
JSSPWD="x"
JSSURL=$( /usr/bin/defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url )
JSSPATH="JSSResource/computers/macaddress"
MACMAC=$( networksetup -getmacaddress en0 | awk '{print $3}' | sed 's/:/./g' )
BUILDING=$( curl -s -u $JSSUSR:$JSSPWD $JSSURL$JSSPATH/$MACMAC | xpath //computer/location/building/text | sed -e 's/<building>//;s/</building>//' )
DEPT=$( curl -s -u $JSSUSR:$JSSPWD $JSSURL$JSSPATH/$MACMAC | xpath //computer/location/department/text | sed -e 's/<department>//;s/</department>//' )
if [[ $BUILDING == "" || $DEPT == "" ]] ;
then
*code here*
fi
I've redacted our api readonly account name and password for security.
The idea is that if either or both of the two fields are blank, the script in the if statement should run. If not, it skips and gets on with the rest of the firstrun script.
What actually seems to happen is that the code in the if statement executes regardless! That's not such a bad flaw at this stage, but it's something i'd like to correct. Any thoughts?