Posted on 05-01-2017 12:15 PM
I have a launch daemon and a script created to run after an OS upgrade. Results are that the daemon runs, and the script but only part of the script is executing. Below is a part of the script, the Turn SSH on piece works as I can verify that in the System preferences, when the script completes it removes the daemon and self destructs, but for some reason jamf policy isn't checking for and running the policies and ASU isn't running. I have the daemon and script in in place to set some preferences, run jamf policy and run ASU on first boot after an OS upgrade we have in Self Service. Any advice?
#!/bin/bash
# Turn SSH on
/usr/sbin/systemsetup -setremotelogin on
#Check for jamf policies
jamf policy
#Run Apple Software Update
softwareupdate -i -a
# Remove setup LaunchDaemon item
/bin/rm -rf /Library/LaunchDaemons/org.name.post_os_upgrade.plist
# Make script self-destruct
/bin/rm -rf $0
Solved! Go to Solution.
Posted on 05-01-2017 01:11 PM
If that's being run as a LaunchDaemon, you have to include the full path to the jamf binary for it to work. It has to do with the default PATH settings used with LaunchDaemons not including /usr/local/bin/
or something like that. It doesn't know what jamf
resolves to, so change it to /usr/local/bin/jamf policy
and it should work I think.
Though that doesn't actually explain why the softwareupdate
command isn't running, I would include the full path to that as well (/usr/sbin/softwareupdate
) to be on the safe side. Maybe it's also not resolving, though it should.
Posted on 05-01-2017 12:41 PM
I ran into this also as the jamf policy check never ran. It'a as though it just skips this. I also manually added a policy check to the jamf startup script and the login script (/Library/Application Support/JAMF/ManagementFrameworkScripts/) but the policy call only kicked off on the loginhook.sh.
I haven't been back to test it out but is the jamf binary not actually running yet when the launchAgent and script kick off?
Posted on 05-01-2017 01:11 PM
If that's being run as a LaunchDaemon, you have to include the full path to the jamf binary for it to work. It has to do with the default PATH settings used with LaunchDaemons not including /usr/local/bin/
or something like that. It doesn't know what jamf
resolves to, so change it to /usr/local/bin/jamf policy
and it should work I think.
Though that doesn't actually explain why the softwareupdate
command isn't running, I would include the full path to that as well (/usr/sbin/softwareupdate
) to be on the safe side. Maybe it's also not resolving, though it should.
Posted on 05-02-2017 05:29 AM
@mm2270 Updated the script and tested overnight. Changing to the full path worked like a charm, thanks very much for the help!