JAMF policy reboots delayed by dialogs

snovak
Contributor

So I have a set of policies that are fired off as part of software updates, and at the end of it I have a reboot dialog. Thing is, the system doesn't seem to reboot until the user acknowledges the dialog.

root 36803   0.0  0.8  2533428  16668   ??  Ss   Thu10PM   0:00.66 
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper 
-windowType hud 
-windowPosition ur 
-lockHUD 
-title Management Action 
-description 
-button1 Submit 
-showDelayOptions 0, 3600, 7200, 14400, 86400, 276967 
-timeout 276967 
-startlaunchd 
-icon /private/tmp/Policy6107.png 

root            65033   0.0  0.8  2527120  16720   ??  Ss    7Jan16   0:00.41 
/usr/local/jamf/bin/jamf reboot 
-message This computer will restart automatically in 20 minutes. Please save anything you are working on and log out by choosing Log Out from the bottom of the Apple menu. You may also select restart from the Apple Menu to restart your computer sooner. 
-minutes 20

root 65039   0.0  0.8  2532676  15968   ??  Ss    7Jan16   0:00.47 
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper 
-windowType utility 
-icon /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/Resources/Restart.png 
-description This computer will restart automatically in 20 minutes. Please save anything you are working on and log out by choosing Log Out from the bottom of the Apple menu. You may also select restart from the Apple Menu to restart your computer sooner. 
-button1 OK 
-defaultButton 1 
-startlaunchd

Does anyone know if this is by design? I would think that marking the reboot delay means that the machine is going to reboot, regardless if the user acknowledges the dialog or not.

11 REPLIES 11

mm2270
Legendary Contributor III

You have a jamfHelper dialog showing up first and then the built in reboot dialog from the policy? Its really unclear how this is set up in your policy based on the log data above. Maybe you can elaborate the sequence you're using?
First glance at this, it seems like the jamfHelper dialog is not being pushed into the background to allow the rest of the script to run. The default way user dialogs work, not just with jamfHelper, but in general, is that they send up a window and wait for that window to exit before running the rest of the script. You can bypass this by adding an ampersand (&) to the end of the line that calls jamfHelper.

I broke the below up with line breaks just so its easier to see where it goes. Also, I would enclose your description text in double quotes to avoid any issues.

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper 
-windowType utility 
-icon /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/Resources/Restart.png 
-description "This computer will restart automatically in 20 minutes. Please save anything you are working on and log out by choosing Log Out from the bottom of the Apple menu. You may also select restart from the Apple Menu to restart your computer sooner." 
-button1 OK 
-defaultButton 1 
-startlaunchd &

snovak
Contributor

I updated the original post with line breaks. Here are some pictures of how I have the policy setup.
7ef0f96e3b224c08902b666977222bbc
ef911c2731c14509a45da34af5b65f0d

bpavlov
Honored Contributor

Yea that's standard behavior which I believe there may be a feature request to change. I'm not sure why an end user is given an out to delay the reboot like this particularly if you've set a time limit of X minutes.

mpermann
Valued Contributor II

@snovak in my experience, using the Restart Options payload delay has that delay countdown only starting once the OK button is clicked. Some of my end users have figured this out. To prevent their computer from restarting, they just leave the dialogue message up on their screen until they are ready to restart the computer. I think in the way you are using it, the behavior is expected.

snovak
Contributor

Yeah I've observed that behavior too, though https://jamfnation.jamfsoftware.com/viewProductFile.html?fid=477 looks promising...

mm2270
Legendary Contributor III

There's a way to call the reboot dialog and begin the countdown in the background in a script, regardless if they click the OK button or not, but by default, the statements above are correct that its expected behavior. Outside of this, its still unclear the number of things you have going on in your policy and I suggest simplifying it a bit. It looks like a jamfHelper dialog, then the reboot dialog, then another jamfHelper dialog? Is that correct? Seems overly complicated how its set up to me.

snovak
Contributor

All this particular policy is doing is installing apple software updates, and then rebooting if it's needed. We hand schedule it for the 3rd weekend of every month, giving users the option to defer the policy until 3AM the following Monday.

The JamfHelpers are all initiated by the User Interaction tab of the policy, I'm not firing them off manually. I'm believe the one talking about reboots is fired off by the jamf reboot -message.

mm2270
Legendary Contributor III

You can push the timer into the background for the reboot by doing something like:

jamf reboot -message "This is the message" -minutes 5 -background

The -background flag is the key to making it NOT wait for the user click the OK button. It would be nice it was an option we could check that on within the built in policy reboot options, but its not there, so the only way to access it right now is through a script.

bpavlov
Honored Contributor

@mm2270 That sounds like a feature request to me....

snovak
Contributor

@mm2270 I actually just tested this and that waits for the user to click 'ok' too...

I think I'm gonna split the message and the reboot into separate processes, figuring that the dialog is the part that's holding up the reboot.

snovak
Contributor

And specifying any amount of delay on the reboot verb throws up a message too, and even says that the countdown starts after the user hits 'ok'!

So I wrote this:

#!/bin/bash
#
# The casper reboot option hardly works, so I'm writing my own
#
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

RESTART="0"
USERS="0"

getRestart() {
    COUNT=$(/usr/sbin/softwareupdate -l | /usr/bin/grep restart | wc -l | tr -d ' ')
    if [ "$COUNT" -ne '0' ]; then
        RESTART="1"
    fi
}

getUserCount() {
    COUNT=$(ls -l /dev/console | awk '/ / { print $3 }' | wc -l | tr -d ' ')
    if [ "$COUNT" -ne '0' ]; then
        USERS="1"
    fi
}

runUpdates() {
    /usr/sbin/softwareupdate -ia
}

rebootPrompt() {
    if [ "$RESTART" == "1" ]; then
        getUserCount
        if [ "$USERS" == "1" ]; then
            /usr/local/bin/jamf displayMessage -message "This computer will restart automatically in 20 minutes. Please save anything you are working on and log out by choosing Log Out from the bottom of the Apple menu. You may also select restart from the Apple Menu to restart your computer sooner."
            # Ping for 20 minutes
            /sbin/ping -c 1200 127.0.0.1 > /dev/null
            /usr/local/bin/jamf reboot -immediately -background
        else
            /usr/local/bin/jamf reboot -immediately -background
        fi
    fi
}

runRecon() {
    if [ "$RESTART" == "0" ]; then
        /usr/local/bin/jamf recon
    fi
}

Main() {
    getRestart
    runUpdates
    runRecon
    rebootPrompt
}

Main "$@"
exit 0