Alternatives to JamfHelper?

DanJ_LRSFC
Contributor III

Can anyone recommend alternatives to jamfHelper? I need something that can:

  • Present a fullscreen message to the user (like -windowType fs in jamfHelper)
  • Runs in the background so my script can continue doing things while the message is showing
  • Allows changing of the message being displayed without having to kill the process and start a new one

Currently I am having to set up all my jamfHelper processes in reverse order at the start of my script, and then kill them individually as appropriate to give the effect of the message changing, this is very clunky and doesn't work very well on some slower machines.

#!/bin/bash

# Get logged in user, the official Apple-approved way
loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
echo "Logged in user is $loggedInUser"

# Stack jamfHelper windows up to start with, kill processes when you want to change message
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Login complete, you may now start using the Mac." &
PID_LOGINCOMPLETE=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Loading PaperCut client..." &
PID_PAPERCUT=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Resetting wallpaper..." &
PID_WALLPAPER=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Restarting Dock..." &
PID_DOCK_RESTART=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Configuring Dock icons..." &
PID_DOCK_CONFIG=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Mounting user's home directory at /Users/$loggedInUser/Documents..." &
PID_MOUNT=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Looking up user's home directory..." &
PID_LOOKUP=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "This Mac is not bound to Active Directory." &
PID_NOAD=$!
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Checking if Mac is bound to Active Directory..." &
PID_CHECKAD=$!
sleep 1
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "Long Road Mac Login" -description "Preparing login, please wait..." &
PID_PREPARING=$!

# rest of script omitted

Can anyone help?

Thanks,
Dan Jackson (Lead ITServices Technician)
Long Road Sixth Form College
Cambridge, UK.

2 REPLIES 2

SimonLovett
New Contributor III

Hi Dan,

I use a bit of osascript to display options to the users and read in their responses. Attached is an example which will get a users response and perform an action based on the response. The script as is simply produces a text file on the desktop which shows which button was pressed, but obviously you can remove those lines and have the users response trigger something else.

If you want the script to carry on running while waiting for a user decision, then you would have to put a & sign or two on the end of a line of bash script which creates the dialogue box, else it will wait for the user to pick a choice.

#############################

Prompt the user

DialogueBoxTitle="IT Services Apple Mac configuration."
DialogueBoxText="This script will help you set up your Mac for managed services. Proceed with Setup?"
DialogueOption1="Yes please"
DialogueOption2="No thanks"
DialogueOption3="Quit"

###########################

Result=$(/usr/bin/osascript<<END
tell application "System Events"
activate
set the answer to the button returned of (display dialog "$DialogueBoxText " with title "$DialogueBoxTitle" buttons {"$DialogueOption3","$DialogueOption2", "$DialogueOption1"})
end tell
END)

##############

getting the answer

touch ~/Desktop/log.txt
if [ "$Result" == "$DialogueOption1" ]; then
echo "User was asked $DialogueBoxText and answered $DialogueOption1" >> ~/Desktop/log.txt
fi

if [ "$Result" == "$DialogueOption2" ];

then
echo "User was asked $DialogueBoxText and answered $DialogueOption2" >> ~/Desktop/log.txt
fi

if [ "$Result" == "$DialogueOption3" ];

then
echo "User was asked $DialogueBoxText and answered $DialogueOption3" >> ~/Desktop/log.txt echo "Script terminated due to users answer" >> ~/log.txt; exit 0
fi

###

Best wishes, Simon.

SimonLovett
New Contributor III

Oh, and there is the timeout argument that can be added as well, which I just found the code for, and you can choose the dialogue style, e.g. caution button. The example closes itself after 20 seconds.

One thing I haven't been able to do is to get it to go fullscreen, but you could set the screen background to white and hide the dock and toolbar - it depends how secure you need it to be.

Result=$(/usr/bin/osascript<<END
tell application "System Events"
activate
set the answer to the button returned of (display dialog "$DialogueBoxText " with title "$DialogueBoxTitle" with icon caution buttons {"$DialogueOption3","$DialogueOption2", "$DialogueOption1"} default button 1 giving up after(20) end tell
END)