I'm on 10.3.1, and I need a command to check a computer's connection to the JSS in a bash script. I've read about the /usr/local/bin/jamf checkJSSConnection
command, but is there a way to limit how many times it will check the connection before it times out? I'm writing a script where I want it to do one thing if there is a JSS connection and do something else if there isn't.
#!/bin/sh
checkJSSConnection=$(/usr/local/bin/jamf checkJSSConnection)
if [[ $checkJSSConnection != *"The JSS is available"* ]]; then
echo "run local script"
sh /path/to/local_script.sh
else
echo "run JSS policy"
jamf policy -event customtrigger
fi
If the JSS is available, it takes only a few seconds to confirm that. If the JSS isn't available it retries for 55-60 seconds, which is longer than I'd like it to take. Any ideas on how to get a quicker response? I talked with Jamf Support and they recommended using jamf recon instead, like this:
#!/bin/bash -v
checkJSSConnection=$(jamf recon)
if [[ $checkJSSConnection != *"There was an error"* ]]; then
echo "run JSS Policy"
jamf policy -event customtrigger
else
echo "run local script"
#sh /path/to/local_script.sh
fi
That has the opposite problem of the prior command, where if the JSS can't recon, it takes only a few seconds to confirm that. If the JSS can recon it takes around 40 seconds for the recon to complete and the script to recognize that, which is a little better but still longer than I'd like it to take.