Skip to main content
Solved

Custom Triggers Script


Forum|alt.badge.img+3

Hi.

I was wondering if there's a script available that will allow me to trigger all of my policies in the order I desire.

Uploaded my current script (not fully grasped the usage of scripts yet)

I'd like it to be a manual trigger for all of my policies but ordered e.g. 10GoogleChrome,20IssueFilevaultkey etc

Please help :D

Best answer by Look

Here's the one I created to run arguments $4 thru $11 as custom triggers.
Just put it in a policy and fill the parameters with the triggers in the order you want them run.

1#!/bin/bash
2echo START
3date
4for Custom_Policy in $(seq 4 11); do
5if [[ "${!Custom_Policy}" ]]; then
6echo Running trigger ${!Custom_Policy}
7jamf policy -event "${!Custom_Policy}"
8fi
9done
10echo FINISH
11date
View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+9
  • Valued Contributor
  • 76 replies
  • December 8, 2017

There are a couple of things you can do here. You can build a global script that runs on enrollment complete, in this script you'd want to make sure that the user is actually logged in before the policies start running. (this sounds like what you're wanting to do, I've attached a script that I use, you can ignore the splashbuddy components.

or

To your first policy that runs at enrollment complete, add a files and processes payload to that policy. In your example, you have a custom event trigger set named to manual_trigger. So in the files and process payload in the last box you would type something like:

1jamf policy -event manual_trigger

This will trigger the policy that you're calling, then in the next policy you'd add another file and processes payload to trigger the following policy and so on, this will set them off like a daisy chain.

I suggest you take a look at a tool called SplashBuddy even if you don't use it you could maybe get a better understanding on how you can manage the order in which you want your policies to run.

Let me know if you have any questions, if you do decide to use splashbuddy, head over the the splashbuddy channel on slack and there are plenty of people there to help you get it setup.

Here is a script that I run on Enrollment Complete, it's the only policy I run at Enrollment complete and it calls all my other policies in order, feel free to cannibalize it any way you want.

1#!/bin/bash
2
3jamfbinary=$(/usr/bin/which jamf)
4doneFile="/Users/Shared/.SplashBuddyDone"
5
6sleep 15
7
8while true
9do
10loggedinuser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
11
12echo $loggedinuser
13
14 if [ "${loggedinuser}" == "root" ] || [ "${loggedinuser}" == "_mbsetupuser" ]; then
15 echo "is root or mbsetupuser"
16 sleep 10
17 else
18 echo "is local user"
19 break
20 fi
21done
22
23echo "Installing SplashBuddy"
24
25${jamfbinary} policy -event "install-SplashBuddy"
26
27echo "Drinking some Red Bull so the Mac doesn't fall asleep"
28caffeinate -d -i -m -u &
29caffeinatepid=$!
30
31echo "Installing Enterpise Connect"
32
33${jamfbinary} policy -event "install-enterpriseconnect"
34
35echo "Installing BlueCoat Certificate"
36
37${jamfbinary} policy -event "install-BCC"
38
39echo "Installing BlueCoat Unified Agent"
40
41${jamfbinary} policy -event "install-BCUA"
42
43echo "Installing Cisco AnyConnect"
44${jamfbinary} policy -event "install-AnyConnect"
45
46echo "Installing Skype For Business"
47${jamfbinary} policy -event "install-sfb"
48
49echo "Installing Citrix Receiver"
50${jamfbinary} policy -event "install-citrix"
51
52echo "Pulling down FileVault 2 configuration"
53${jamfbinary} policy -event "requireFV2"
54
55echo "Setting up Dock"
56${jamfbinary} policy -event "setDock"
57
58echo "Adobe Reader"
59${jamfbinary} policy -event "adobereader"
60
61echo "Installing Microsoft Office"
62${jamfbinary} policy -event "install-office"
63
64echo "Installing VPN Settings"
65${jamfbinary} policy -event "install-vpnsettings"
66
67echo "Certificate Import"
68${jamfbinary} policy -event "certimport"
69
70echo "Enterprise Connect launcher"
71${jamfbinary} policy -event "eclauncher"
72
73serial_number=`ioreg -l | grep IOPlatformSerialNumber|awk '{print $4}' | cut -d " -f 2`
74/usr/sbin/scutil --set ComputerName $serial_number
75/usr/sbin/scutil --set LocalHostName $serial_number
76/usr/sbin/scutil --set HostName $serial_number
77
78sleep 10s
79
80#adbind uses a files and processes payload to call "finalsetup"
81echo "Active Directory Binding"
82${jamfbinary} policy -event "adbind"
83
84echo "Creating done file"
85touch "$doneFile"
86
87echo "Quitting SplashBuddy"
88osascript -e 'quit app "SplashBuddy"'
89
90echo "Unloading and removing Splashbuddy Launchagent"
91launchctl unload /Library/LaunchDaemons/io.fti.splashbuddy.launch.plist
92rm -f /Library/LaunchDaemons/io.fti.splashbuddy.launch.plist
93
94echo "Deleting SplashBuddy"
95rm -rf "/Library/Application Support/SplashBuddy"
96
97echo "Deleting lunch agent"
98launchctl remove io.fti.SplashBuddy.launch
99
100echo "Drank waaaayyyyy too much Red Bull"
101kill "$caffeinatepid"
102
103
104# OS X Version check potential
105
106sw_vers_MajorNumber=`/usr/bin/sw_vers -productVersion | /usr/bin/cut -d. -f 2`
107
108# Restart in 5 seconds if version above 10.12
109if [ $sw_vers_MajorNumber -ge 12 ]; then
110 echo "software is 10.12 or lower"
111 kill -9 `pgrep loginwindow`
112else
113 echo "software is over 10.12"
114 /sbin/reboot
115fi

Forum|alt.badge.img+16
  • Valued Contributor
  • 1002 replies
  • Answer
  • December 10, 2017

Here's the one I created to run arguments $4 thru $11 as custom triggers.
Just put it in a policy and fill the parameters with the triggers in the order you want them run.

1#!/bin/bash
2echo START
3date
4for Custom_Policy in $(seq 4 11); do
5if [[ "${!Custom_Policy}" ]]; then
6echo Running trigger ${!Custom_Policy}
7jamf policy -event "${!Custom_Policy}"
8fi
9done
10echo FINISH
11date

Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 2 replies
  • December 14, 2017

Thanks Guys!


Forum|alt.badge.img+3

@LovelessinSEA

I am curious about the details of how splashbuddy works with your policies names and package names. i haven't delved into Splashbuddy very far, so excuse my ignorance. From your script you aren't using the naming scheme that is recommended on the Splashbuddy Kickstart guide for your policies.

Is this because you are not using the enrollment trigger for you software installation and instead using a custom script to fire off the installs?

Thanks for you post, it helped me break through some issues I was having.


Forum|alt.badge.img+9
  • Valued Contributor
  • 76 replies
  • January 30, 2018

@matthew.johnson You are correct. I chose to use a global script to fire off all of the policies instead of relying on the 01, 02, 03 naming convention. I chose this method along with a files and process payload to handle other policies to they fire off in a very specific order. This allows me to troubleshoot any issues that arise with my enrollment workflow.

You still must use the required splashbuddy naming convention for the package names, ie anyconnect-4.5.pkg


Forum|alt.badge.img+10
  • Contributor
  • 61 replies
  • January 30, 2018

nice script @LovelessinSEA


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings