Jamf Helper Deferral, Exceeded Deferral, Force Install

KMak84
Contributor

I managed to use the jHelper GUI to do the more basic things to notify the users but need a to see if anyone has a one size fits all for application deployment using Jamf Helper.

Is there a way to force the the install of any application after they reached for example 5 deferrals. With Login, log out hooks gone, need to be more lets put this nicely user friendly when deploying updated apps.

This is something I have used that works but need it to force the install after numerous deferrals

#!/bin/sh

####################################################################################################
#
# HISTORY
#
#   Version: 1.0
#
#   - Created by Douglas Worley, Professional Services Engineer, JAMF Software on May 10, 2013
#
####################################################################################################
# The recursively named JAMF Helper help file is accessible at:
# /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -help

windowType=""         #   [hud | utility | fs]
windowPosition="" #   [ul | ll | ur | lr]
title=""          #   "string"
heading=""            #   "string"
description=""        #   "string"
icon=""               #   path
iconSize=""           #   pixels
timeout=""            #   seconds


[ "$4" != "" ] && [ "$windowType" == "" ] && windowType=$4
[ "$5" != "" ] && [ "$windowPosition" == "" ] && windowPosition=$5
[ "$6" != "" ] && [ "$title" == "" ] && title=$6
[ "$7" != "" ] && [ "$heading" == "" ] && heading=$7
[ "$8" != "" ] && [ "$description" == "" ] && description=$8
[ "$9" != "" ] && [ "$icon" == "" ] && icon=$9
[ "$10" != "" ] && [ "$iconSize" == "" ] && iconSize=$10
[ "$11" != "" ] && [ "$timeout" == "" ] && timeout=$11

function setSnooze ()
{

## Get the time right now in Unix seconds
timeNow=$(date +"%s")
## Calculate the time for the next available display of the prompt (adds the time now and time chosen together in seconds)
timeNextRun=$((timeNow+SnoozeVal))

## Create or update a plist value containing the above next time to run value
/usr/bin/defaults write /Library/Preferences/com.acme.policy_001.snooze.plist DelayUntil -int $timeNextRun

exit 0

}

function showPrompt ()
{

## Prompt, and capture the output
HELPER=$("/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" -windowType "$windowType" -windowPosition "$windowPosition" -title "$title" -heading "$heading" -description "$description" -icon "$icon" -iconSize "$iconSize" -button1 Install Now” -button2 Snooze -defaultButton 2 -cancelButton "2"  -timeout "$timeout" -countdown -lockHUD -showDelayOptions "300, 900, 1800, 3600, 7200, 14400, 86400")

echo "jamf helper result was $HELPER"

## Dissect the response to get just the button clicked and the value selected from the drop down menu
ButtonClicked="${HELPER: -1}"
SnoozeVal="${HELPER%?}"

echo "$ButtonClicked"
echo "$SnoozeVal"

if [ "$ButtonClicked" == "1" ]; then
    echo "User chose Install"
    /usr/local/jamf/bin/jamf policy -trigger office2019
    exit 0
elif [ "$ButtonClicked" == "2" ]; then
    echo "User chose Snooze"
    setSnooze
fi

}

## Get a value (if possible) from a plist of the next valid time we can prompt the user
SnoozeValueSet=$(/usr/bin/defaults read /Library/Preferences/com.acme.policy_001.snooze.plist DelayUntil 2>/dev/null)

## If we got something from the plist...
if [ -n "$SnoozeValueSet" ]; then
    ## See what time it is now, and compare it to the value in the plist.
    ## If the time now is greater or equal to the value in the plist, enough time has elapsed, so...
    timeNow=$(date +"%s")
    if [[ "$timeNow" -ge "$SnoozeValueSet" ]]; then
        ## Display the prompt to the user again
        showPrompt
    else
        ## If the time now is less than the value in the plist, exit
        echo "Not enough time has elapsed. Exiting..."
        exit 0
    fi
else
    ## If no value was in the plist or the plist wasn't there, assume it is the first run of the script and prompt them
    showPrompt
fi

Any input would be great

0 REPLIES 0