Logout Script with the Option to Cancel logout

ccasteel
New Contributor II

Is there a way you can write a bash script to bring up a Jamf helper option with 2 buttons? OK and Cancel.

With OK continuing on with the script and then logging out.

But if the user clicks cancel it would actually cancel the logout and put them back to the desktop?

5 REPLIES 5

avogel
New Contributor II

Hello, of course it is possible that a button in Jamfhelper performs a certain button action. Here is an example:

ELPER=$("$jamfHelper" -windowType utility -icon "$KeychainIcon" -title "Change Keychain password" -description "$Message" -button1 "OK" -button2 "Cancel" -cancelButton "2" -defaultButton 2) echo "Jamf Helper Exit Code: $HELPER" if [ "$HELPER" == "0" ] then

skeenan07
New Contributor III

I wrote an auto-logout script in zsh last month that prompts the user after a specified idle time and restarts the Mac. You can find the script here.

Anonymous
Not applicable

Excellent script @skeenan07 .  I've been looking at how to deal with the devices that are hanging due to open programs or something when I have the config file set to auto log out, so finding your post is fantastic.  How do you go about leveraging it within JAMF? is it run at login or set differently?  

skeenan07
New Contributor III

Hey @Anonymous. I created a package that drops the script at /Library/Scripts/autoLogout/ and a launch daemon in /Library/LaunchDaemons/. The launch daemon runs the script every five minutes to check the idle time. If it has exceeded the time, the script will display the popup and log out if the user does not respond. I have a post-install script in the package to load the launch daemon. In Jamf, I created a policy to install the package on some of our labs at their next check-in. I have more info here

Anonymous
Not applicable

Thanks for the info and also for the links.  I was missing the LD portion.  Many thanks for your work on something like this, its semi mind numbing the work that goes into a simple boot out process...