Greetings, all! I'm fine tuning a JAMF Helper script that I have in place to upgrade with an OS X installer using simple caching. Between the caching and the actual installation of the OS X installer, I want to use a JAMF Helper window to notify the end user of the process, allowing them to opt-in and opt-out.
I am noticing that the notification (running at recurring check-in, once per day) is capable of running when no one is logged onto the computer. This displays the JAMF Helper window at the login screen and eventually just times out. Here is what I would like to accomplish, with your help:
Echo that a timeout has been reached using "243 - The window timed-out with no buttons on the screen."
Before the JAMF Helper command runs, check to see if the logged in user (loggedInUser=$(stat -f%Su /dev/console)) is actually logged onto the computer.
#!/bin/bash
/usr/bin/curl -s -o /tmp/elcapitan_icon.png http://assets.materialup.com/uploads/ec819071-7140-4c6d-89ac-81b712642fcb/512x512bb-85.png
loggedInUser=$(stat -f%Su /dev/console)
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
windowType="hud"
description="Your <Organization>-issued computer is not currently running the latest OS X version. To perform the OS X El Capitan update, select 'UPDATE' below and the upgrade will begin to run. Once complete, your computer will restart immediately. If you are unable to perform this update at the moment, please select 'Cancel.'
*Please save all working documents before selecting 'UPDATE.'
If you require assistance, please contact the Helpdesk by phone at <PhoneNumber> or by email at <EmailAddress>."
button1="UPDATE"
button2="Cancel"
icon="/tmp/elcapitan_icon.png"
title="Update Available: Install OS X El Capitan"
alignDescription="left"
alignHeading="center"
defaultButton="2"
timeout="10"
userChoice=$("$jamfHelper" -windowType "$windowType" -lockHUD -title "$title" -timeout "$timeout" -defaultButton "$defaultButton" -icon "$icon" -description "$description" -alignDescription "$alignDescription" -alignHeading "$alignHeading" -button1 "$button1" -button2 "$button2")
if [ "$userChoice" == "0" ]; then
echo "$loggedInUser clicked UPDATE; now running OS X El Capitan Installer via JSS policy ID 547."
jamf policy -id 547
elif [ "$userChoice" == "2" ]; then
echo "$loggedInUser clicked Cancel; now exiting."
exit 0
elif [ "$userChoice" == "243" ]; then
echo "Timeout was reached; now exiting."
exit 0
fi