Help with a post-install custom trigger

loftus
New Contributor II

I’m trying to get a post-install script to run from a custom trigger. This seems like it should be fairly straight forward so I assume I’m overlooking something quite basic? And yes, I am a noob in terms of scripting so please go easy on me. Or not! I just can't figure out what I'm doing wrong...

Following a suggested imaging Workflow on Macmule I’ve created postflight.sh like this:

#!/bin/bash

jamf policy -event postflightconfig

Which has then been set to run at reboot as part of this imaging config:

e12a3d067964486bb99a354ae7887115

With the policy itself set to trigger at a custom event defined as postflightconfig, like this:

f253abe7ab17471aa11b460d69b0b8d3

Except nothing happens?

If I make postflight.sh executable I can run it manually and the policy is successfully triggered so I know the trigger and policy are OK. I just can’t get it to run at reboot after imaging?

JSS is 9.81

Thanks in advance...

1 ACCEPTED SOLUTION

loftus
New Contributor II

Solved with help from @CasperSally's post here

View solution in original post

7 REPLIES 7

davidacland
Honored Contributor II
Honored Contributor II

It all looks correct to me.

The problem sounds like the Casper imaging process isn't triggering the script.

I would take a look at the casper imaging log for a device you've tested it on, and/or look in the /var/log/jamf.log file on the client to see if there are any clues.

thoule
Valued Contributor II

I'm not sure the environment variables in your setup. You might want to use the full path to the JAMF binary

/usr/local/jamf/bin/jamf policy -event postflightconfig

bpavlov
Honored Contributor

Any difference between /usr/local/jamf/bin/jamf
and
/usr/local/bin/jamf
?

thoule
Valued Contributor II

/usr/local/bin/jamf is a symlink (alias) that points to /usr/local/jamf/bin/jamf. The former is likely safer in long term scripts. The latter is the real binary.

loftus
New Contributor II

Log shows the policy being triggered but it's unable to connect to the JSS? Looking at the sequence the custom event runs before any of the JAMF items. Do I need to alter the sequence so that it runs after default JAMF management stuff has been applied? If so how do I do that exactly?

2016-3-15 10:37:58 Formatted Macintosh HD
Tue Mar 15 10:37:59 NetBoot018 jamf[881]: Installing create_ladmin_1.1.pkg...
Tue Mar 15 10:38:00 NetBoot018 jamf[881]: Successfully installed create_ladmin_1.1.pkg.
Tue Mar 15 10:38:02 NetBoot018 jamf[946]: Creating .AppleSetupDone...
Tue Mar 15 10:39:32 MBA jamf[201]: Checking for policies triggered by "postflightconfig"...
Tue Mar 15 10:39:34 MBA jamf[201]: Could not connect to the JSS. Looking for cached policies...
Tue Mar 15 10:39:49 MBA jamf[300]: Creating user casper...
Tue Mar 15 10:40:19 MBA jamf[300]: Enforcing management framework...
Tue Mar 15 10:40:25 MBA jamf[300]: Enforcing scheduled tasks...
Tue Mar 15 10:40:25 MBA jamf[300]: Adding launchd task com.jamfsoftware.task.1...
Tue Mar 15 10:40:26 MBA jamf[300]: Creating launch daemon...
Tue Mar 15 10:40:26 MBA jamf[300]: Downloading the agent...
Tue Mar 15 10:40:26 MBA jamf[300]: Creating launch agent...
Tue Mar 15 10:40:27 MBA jamf[746]: Informing the JSS about login for user _mbsetupuser
Tue Mar 15 10:40:29 MBA jamf[756]: Checking for policies triggered by "enrollmentComplete"...
Tue Mar 15 10:40:32 MBA jamf[756]: Upgrading JAMF notification service...
Tue Mar 15 10:40:33 MBA jamf[756]: Upgrading Self Service.app...
Tue Mar 15 10:40:33 MBA jamf[746]: Informing the JSS about login for user ladmin
Tue Mar 15 10:40:41 MBA jamf[952]: Checking for policies triggered by "startup"...

Thanks again..

loftus
New Contributor II

Solved with help from @CasperSally's post here

CasperSally
Valued Contributor II

@loftus glad it helped someone!