create LaunchDeamon to run a script - recon on connection to JSS

kdrossos
New Contributor

Hi guys,
i have the following issue:
we are still on Mojave and are in the process of upgrading to catalina.
Eitherway we will upgrad evia Munki or the JSS.
But it occured to me that if i run a policy via Jamf, sometimes the policy starts, but is still pending after the update to Catalina was successful. And the policy starts again, because there was no inventory update to check that now Catalina is installed which is excluded via Smartgroup.

If i update via Munki, it also takes some time to update the inventory.
I would like to update the jamf inventory right at connection, so the configuration profiles for the PPPC for Catalina can be applied right at startup.

The other issue is that most of our users are in home office and are connection via VPN.
So the JSS is just aviable via VPN.

So my idea was the following:
a LaunchDeamon to launch a script at startup of the Mac.
The scripts trys to ping the JSS via IP with a loop.
if the ping is succesful it will stop and start a recon command.

Now the script itself works when used via the Terminal.
I checked the LaunchDeamon via Launch Control and this seems also to work but returns with Status 78.
The permissions and ownerships of both files are set.
Permissions: 664 ; root:wheel

launchD:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.GT.checkJSSonline1.plist</string> <key>ProgramArguments</key> <array> <string>/Library/Scripts/check_jss_online.sh </string> </array> <key>RunAtLoad</key> <true/> <key>UserName</key> <string>root</string> </dict> </plist>

Script to ping our JSS: (ip adress was changed)

#!/bin/sh

while true;
do
  ping -c1  8.8.8.8
  if [ $? -eq 0 ]
  then
    jamf recon
    exit 0
  fi
done

I have no idea where i can look at.

Or maybe you got another idea how i can achieve this.
Thank you very much in advance.

KR,
Konstantin

2 REPLIES 2

donmontalvo
Esteemed Contributor III

Should be root:wheel and 644.

--
https://donmontalvo.com

bradsschroeder
New Contributor III

I have updated the tags from Jamf Nation to JSS and Scripts to more closely align with the conversation. Please let me know if you disagree.