Skip to main content
Solved

Use jamfHelper to notify of Self Service policies waiting

  • February 19, 2013
  • 27 replies
  • 156 views

Show first post

27 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • February 28, 2023

@mm2270 Im looking at having it maybe use some error handling/logging for each policy trigger as it goes and then try running any failed commands 3 more times....  This is what I have so far to add to it any suggestions?

 

## Call the Jamf policy by its event trigger and retry if it fails success=0 while [ $success -eq 0 ]; do /usr/local/bin/jamf policy -event "$trigger" if [ $? -eq 0 ]; then success=1 else echo "Policy failed, retrying in 10 seconds..." sleep 10 fi done

 

Or maybe something like this?

## Function that calls each policy trigger and customizes the message during each loop ## Uses a case statement to determine the heading text for each custom event trigger function callPolicy () { local tries=0 local success=0 ## This case statement determines which heading text we need to use in jamfHelper for each policy trigger case $trigger in rosetta) heading_text="Rosetta if needed" ;; policy) heading_text="Outstanding Policies" ;; SSO) heading_text="Microsoft Company Portal" ;; creativecloud) heading_text="Creative Cloud if needed" ;; Office2019) heading_text="Microsoft Office" ;; chrome) heading_text="Google Chrome" ;; firefox) heading_text="Mozilla Firefox" ;; zoom) heading_text="Zoom" ;; CocoaDialogue) heading_text="AUP" ;; dockutil) heading_text="Set Dock Utility" ;; desktoppr) heading_text="Set Desktop Utility" ;; umbrella) heading_text="Cisco Umbrella if needed" ;; testnav) heading_text="TestNav" ;; firmware) heading_text="Firmware Password if needed" ;; recon) heading_text="Running Final Recon" ;; esac while [ $tries -lt 3 ] && [ $success -eq 0 ] do ## Call jamfHelper and customize the display slightly "$jamf_helper" \\ -windowType utility \\ -title "Base App Installs" \\ -heading "$heading_text" \\ -description "Completing Step $i of $total_steps" \\ -icon "$icon" & ## Call the Jamf policy by its event trigger /usr/local/bin/jamf policy -event "$trigger" ## Check if the policy call was successful if [ $? -eq 0 ]; then success=1 else tries=$((tries+1)) sleep 2 killall jamfHelper fi done }

 


Hey @GabePPS I think capturing the policy exit status the way you're doing in your first example should work, but it's of course something you'll need to test out. As long as each policy trigger is in fact calling a policy from Jamf Pro, then that should be ok.


Forum|alt.badge.img+18
  • Esteemed Contributor
  • March 1, 2023

Hey @GabePPS I think capturing the policy exit status the way you're doing in your first example should work, but it's of course something you'll need to test out. As long as each policy trigger is in fact calling a policy from Jamf Pro, then that should be ok.


@mm2270 Thanks! So Im trying something like this to combine the two ideas, just to keep it from looping forever like you had suggested in another script you helped with.

# Set the maximum number of times to retry the policy max_retry_count=3 # Call the Jamf policy by its event trigger and retry if it fails retry_count=0 success=0 while [ $retry_count -lt $max_retry_count ] && [ $success -eq 0 ]; do /usr/local/bin/jamf policy -event "$trigger" if [ $? -eq 0 ]; then success=1 else echo "Policy failed, retrying in 10 seconds..." retry_count=$((retry_count+1)) sleep 10 fi done