Skip to main content
Solved

Running a policy as a result of a script?

  • October 31, 2014
  • 4 replies
  • 31 views

Forum|alt.badge.img+6

Hi all,

So I'm working on a policy to run when no user is logged into their machine. We run 24 hours here and desks are randomly filled. I have the logic of determining if a user is logged in or not already handled via a shell script. What I need, is some way to determine if a script should run or not depending on the result of the script *in real time*. I can run this as an extension attribute, but those only update at specific intervals. Smart groups are also dependent on the recon. I was thinking about doing this via a cron or something else outside of JSS, but I'd prefer to keep it inside the JSS and it's framework if at all possible. Any suggestions? Perhaps a feature set I'm overlooking or somewhere where somebody has already done something similar?

Best answer by bvrooman

You could set a custom trigger on the policy and then set a script to run as another 'ongoing' policy. This would evaluate the script each checkin, and then that script could be set to run 'jamf policy -event <customEvent>' based on the results.

4 replies

Forum|alt.badge.img+16
  • Valued Contributor
  • Answer
  • October 31, 2014

You could set a custom trigger on the policy and then set a script to run as another 'ongoing' policy. This would evaluate the script each checkin, and then that script could be set to run 'jamf policy -event <customEvent>' based on the results.


donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • October 31, 2014

Script to determine if current user is root, if so trigger a policy. Might want to toss up a dialog box if you do this.

[EDIT: Sorry @bvrooman looks like I posted a second after you did!]


Forum|alt.badge.img+13
  • Valued Contributor
  • October 31, 2014

Create a policy with a custom trigger and call it from your script with

jamf policy -trigger yourcustomtrigger

or

jamf policy -event yourcustomtrigger

, both should work


Forum|alt.badge.img+6
  • Author
  • Contributor
  • November 3, 2014

All responses were great.