Boot Script Help

TomDay
Release Candidate Programs Tester

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
1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

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.

View solution in original post

3 REPLIES 3

engh
New Contributor III

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?

mm2270
Legendary Contributor III

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.

TomDay
Release Candidate Programs Tester

@mm2270 Updated the script and tested overnight. Changing to the full path worked like a charm, thanks very much for the help!