using jamfHelper before AND after an installation? try this....

themacdweeb
Contributor

I've been running into issues over the years with how to best alert users to our installations. Our users wants notice before and after each install. Fair enough. We usually update when a user logs in but we also sometimes install at startup, before any user logs in. After trying applescript and growl (both of which cannot handle messaging if a user isn't logged in, we switched over to jamfHelper. Which has been great.

The idea: use a fullscreen message/lockout during the install, and a second "sticky" utility window after the install is complete, forcing the user to click "OK" and confirm the message.

The problem: jamfHelper makes our mouse/trackpads/keyboards function oddly. The keyboards lose functionality and all clicks get interpreted as right clicks. Bummer. After working on a few solutions to kill jamfHelper, I learned that I also need to kill system events. Below is the script we now use on all installations.

What happens before this script is a jamfHelper call to pop up a fullscreen alert. What happens after this script is a SECOND jamfHelper call to pop-up a utility window alert that forces the user to click a button. The sleep calls are so that the commands don't over-run one another.

Hope this helps the community.

#!/bin/bash
# script used to reset user's I/O devices when running jamfHelper twice in a policy

sleep 5
sudo killall jamfHelper ## kills the process

sleep 2
sudo killall System Events ## kills the wonky I/O issues

sleep 2

exit 0

23 REPLIES 23

dpertschi
Valued Contributor

I'd love to get the basic functionality of a full screen message lock to work right...

When use this before script, my package install and subsequent kill jamfHelper script don't run. Once I kill the jamfHelper, then my package will install. Am I missing something in the before script to allow other processes to occur in the background?

#!/bin/sh

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "Updating" -description "Macintosh software updates are being applied. Please stand by..." -icon /System/Library/CoreServices/Software Update.app/Contents/Resources/Software Update.icns

exit 0

thanks for any help,
Darrin

rob_potvin
Contributor III
Contributor III
#!/bin/sh

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "Updating" -description "Macintosh software updates are being applied. Please stand by..." -icon /System/Library/CoreServices/Software Update.app/Contents/Resources/Software Update.icns  &

you want to follow your jamfHelper call with an & symbol

I had the same problem...

Think that Tom (Yoda) told me about it...

dpertschi
Valued Contributor

Yes! That'll do it!

Crummy ampersand cost me 2 hours, grrrr.

Thanks a ton!

rob_potvin
Contributor III
Contributor III

Make sure that you kill it after the policy that was run. for example

jamfHelper switches &
jamf policy -trigger nameofpolicy
killall jamfHelper

That is what I use for my software update policy. Check to make sure its plugged in, then hit okay, full screen update, trigger and restart

Cheers

ernstcs
Contributor III

"Crummy ampersand cost me 2 hours, grrrr."

I think everyone should always come here for questions no matter how simple or stupid you think they may be and save yourself some time. Don't try to reinvent.

If you can't seem to figure something out in the first 30 minutes I'd fire off a message to this list, you might save yourself a lot of time!

matt4836
Contributor II

So I can't get this jamfHelper deal to work at all. What does the "&" do? I have never used that in scripting.

Thanks!

matt4836
Contributor II

Apparently hitting publish twice does this.

stevewood
Honored Contributor II
Honored Contributor II

The ampersand (&) is a *NIX directive to tell the system to run the command in the background. By putting the & at the end of the jamfHelper call, you are telling the system to run jamfHelper in the background and move on to process the rest of your script.

In the case of a policy, you are letting the next process in the policy go. So if your jamfHelper script is set to run as a Before item, the policy will continue on to the next step, like installing software or running whatever other steps you have.

What troubles are you having with jamfHelper?

Steve

matt4836
Contributor II

Thanks for the quick response!! That will actually help a million with a compressor script I wrote. Client wanted two video to encode simultaneously. That will do it!

I can't get it to do anything. I am running it directly from Terminal to learn its function. For one, I have to sudo shell to see the thing. I was logged in a test user that is non admin. I tried ln -s to /usr/sbin but got permission denied when ran as standard user.

I saw jamfHelper at the regional conference yesterday and wanted to play along :-)

matt4836
Contributor II

let me specify I did the LN -s as sudo. Got it to soft link, but could not execute the soft link.

EDIT: I think I miss typed -windowType hud I realized it was returning 255 which means no window mode displayed. Opps. It's working now, my first rule of troubleshooting "Suspect User Error."

Thanks for the & tip!!!

stevewood
Honored Contributor II
Honored Contributor II

I use a script to fire off jamfHelper here. It's a script that was written by one of my counterparts in our Des Moines office, and the main line of code that calls jamfHelper is this:

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -icon "$iconpath$icon" -heading "$heading" -description "$description" &

Now, we use different icons and headings and descriptions, all passed as $4, $5, $6 variables from Casper. If you want to test jamfHelper to see how it works, you should ssh into a different box, then issue this:

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs &

That will run jamfHelper in full screen mode (fs) and give you an idea of what it will do. Once you are done testing, just issue:

killall jamfHelper

And that should bring you back to the normal screen. You'll want to do this on a box that is near you, or one that you can ARD or VNC into so you can see the behavior.

From there, you can keep playing around until you figure out the switches you want to use.

Make sense?

Steve

matt4836
Contributor II

Yes. That makes complete sense! I see where I went wrong, thank you so much!

daniel_behan
Contributor III

Steve,

Do you use any permutation of that script to include a yes/no button? I have the $4 $5 $6 variables set for icon, heading and description. What I need is for something like a $7 RESPONSE for a Yes button to fill in a $8 trigger with a no simply exiting the script.

I'm getting an EOF error on the line where I'm trying to put it all together at:

$RESPONSE='/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

I pulled some of this by using displayMessage.sh from the Resource Kit as a template and using lisacherie's script from https://jamfnation.jamfsoftware.com/featureRequest.html?id=751

-Dan

jarednichols
Honored Contributor
$RESPONSE='/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

I think your issue is that after your = you have a single quote and not a grave (`). It should be:

$RESPONSE=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

daniel_behan
Contributor III

Jared,

Thanks for the quick reply. I have the ( ` ) symbol. I'm wondering if the issue is that I'm depending on someone clicking "Yes" as a means of entering whatever manual trigger I'll specify in field 8 of the policy. Here's the whole script:

#!/bin/sh

# HARDCODED VALUES ARE SET HERE
icon=""
heading=""
description=""
RESPONSE=""
trigger=""

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "icon"
if [ "$4" != "" ] && [ "$icon" == "" ]; then icon=$4
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 5 AND, IF SO, ASSIGN TO "heading"
if [ "$5" != "" ] && [ "$heading" == "" ]; then heading=$5
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 6 AND, IF SO, ASSIGN TO "description"
if [ "$6" != "" ] && [ "$description" == "" ]; then description=$6
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 7 AND, IF SO, ASSIGN TO "RESPONSE"
if [ "$7" != "" ] && [ "$RESPONSE" ] == "" ]; then RESPONSE=$7

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 8 AND, IF SO, ASSIGN TO "trigger"
if [ "$8" != ""] && [ "$trigger" == "" ]; then trigger=$8
fi

####################################################################################################
# # SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################

if [ "$icon" == "" ]; then echo "Error: The parameter 'icon' is blank. Please specify an icon to be displayed." exit 1
fi

if [ "$heading" == "" ]; then echo "Error; The parameter 'heading' is blank. Please specify a heading to be displayed." exit 1

if [ "$description" == "" ]; then echo "Error: The parameter 'description' is blank. Please specify a description to be displayed." exit 1

if [ "$RESPONSE" == "" ]; then exit 0

if [ "$trigger" == "" ]; then echo "Error: The parameter 'trigger' is blank. Please specify a description to be displayed." exit 1
fi

$RESPONSE='/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

if [ "$RESPONSE" == "0" ]; then /usr/sbin/jamf policy -trigger "$trigger" exit 0
else
echo "user chose No";
exit 1
fi

stevewood
Honored Contributor II
Honored Contributor II

You have a single quote ' right after the equal sign instead of a grave ` :

yours:

$RESPONSE='/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

mine:

$RESPONSE=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "Cancel" -cancelButton "2"`

daniel_behan
Contributor III

Good catch Steve!
I just put that in and now I only get:
"Script exit code: 2
Script result: line 70: syntax error: unexpected end of file"

line 70 is the last line of the script:
"fi"

-Dan

henkelb
New Contributor III

It looks like you are missing a few "fi" statements for your if statements earlier in the script.

jarednichols
Honored Contributor
You have a single quote ' right after the equal sign instead of a grave ` :

Isn't that what I said?? :)

daniel_behan
Contributor III

Jared,

It is indeed. I misread your comments and saw the ` at the end of the statement instead of at the beginning. Sorry for the confusion. Thanks for the input everyone. I'll share the result of the script when it works.

-Dan

daniel_behan
Contributor III

Thank you all for your help. I got it. Special thanks to stevewood for the idea of using a templated script in a policy, to lisacherie for the jamfHelper script and to jarednichols and henkelb for the finishing touches needed to make it work. Here it is if anyone needs it:

#!/bin/sh

# HARDCODED VALUES ARE SET HERE
icon=""
heading=""
description=""
trigger=""

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "icon"
if [ "$4" != "" ] && [ "$icon" == "" ]; then
icon=$4
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 5 AND, IF SO, ASSIGN TO "heading"
if [ "$5" != "" ] && [ "$heading" == "" ]; then heading=$5
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 6 AND, IF SO, ASSIGN TO "description"
if [ "$6" != "" ] && [ "$description" == "" ]; then description=$6
fi

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 7 AND, IF SO, ASSIGN TO "trigger"
if [ "$7" != "" ] && [ "$trigger" == "" ]; then trigger=$7
fi

####################################################################################################
# # SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################

if [ "$icon" == "" ]; then
echo "Error: The parameter 'icon' is blank. Please specify an icon to be displayed."
exit 1
fi

if [ "$heading" == "" ]; then echo "Error: The parameter 'heading' is blank. Please specify a heading to be displayed." exit 1
fi

if [ "$description" == "" ]; then echo "Error; The parameter 'description' is blank. Please specify a description to be displayed." exit 1
fi

if [ "$trigger" == "" ]; then echo "Error: The parameter 'trigger' is blank. Please specify a trigger to be displayed." exit 1
fi

RESPONSE=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$icon" -heading "$heading" -description "$description" -button1 "Yes" -button2 "No" -cancelButton "2"

echo "jamf helper result was $RESPONSE";

if [ "$RESPONSE" == "0" ]; then /usr/sbin/jamf policy -trigger "$trigger" exit 0
else echo "user chose No"; exit 1
fi

jhbush
Valued Contributor II

How hard would it be to add timer logic and a counter file variable that could be defined like the numbered variables?

monaronyc
Contributor

@daniel.behan I know it's been a while since this posting but just wondering if you're still using the same script above with El Cap and Sierra users. Not to mention High Sierra. Looking for something like this for my users. A before and after kind of thing.