Chaining AutoPkg Packages Install then Script

HichemBM
New Contributor

Hi there,

I'm trying to chain two steps to setup new computers :
1/ Install Chrome and Slack, which have their packages auto generated, updated and cached thanks to autopkg
2/ Once both are installed, run a script to set the dock in a clear state with dockutil

I already have the different policies (one for each package, one for the script) running separately, but what I want to achieve is running the dock policy right after the apps are installed. If the dock resets before installing the apps, it results in "?" appearing instead of the app icon, and it doesn't launch anything when clicking on it.

I thought about using custom events, but, if I'm not mistaken, I can't configure a policy to trigger an event, only a script or a package. But the app packages for Chrome and Slack are auto generated, with the policy all together, so I can't configure these to trigger custom events.

I don't see a way of triggering the policies in the proper order.
Any ideas ?

Thanks !

2 REPLIES 2

mm2270
Legendary Contributor III

If you're running a script in any portion of the policy, which is what it sounds like, you can use a custom trigger to call the policies in the order you want, meaning, jamf policy -trigger policy1 then jamf policy -trigger policy2, etc. But of course you need to check the custom trigger box for those policies and enter something in the text field that your script will be able to call. If you only enable the custom trigger field, you can scope the policy to all managed Macs and it won't get run until its called manually by that trigger, which saves you from needing to create Smart Groups as a scope for them.

If you need to trigger the dockutil policy last, after the installs, then you can add the above jamf policy line into the Run command field in your second install policy and it will call that dockutil policy after it completes.

Does that make sense?

HichemBM
New Contributor

Thanks for your answer. With you help and some attempts, I achieved doing what I was aiming.

I ended up updating the policies to run at the same time the package install (Chrome and Slack) and the dockutil script, since the policy templates used by autopkg allow that. I just tested inside the dockutil script if the app exists before trying to insert it into the dock.

That way, when a new user is enrolled, it checks for policies and detects the two policies, each one installing an app and executing the dockutil script. It restarts the dock twice, but it's ok because it doesn't show the ? anymore.

Thanks, you've helped leading me into the good direction. Cheers!