Running a policy as a result of a script?

jardoin1
New Contributor III

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?

3 ACCEPTED SOLUTIONS

bvrooman
Valued Contributor

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.

View solution in original post

donmontalvo
Esteemed Contributor III

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!]

--
https://donmontalvo.com

View solution in original post

Chris
Valued Contributor

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

View solution in original post

4 REPLIES 4

bvrooman
Valued Contributor

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
Esteemed Contributor III

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!]

--
https://donmontalvo.com

Chris
Valued Contributor

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

jardoin1
New Contributor III

All responses were great.