Here's a script that you can use to get you going in the right direction I think. I haven't thoroughly tested all aspects of this, but quick tests show that it works. There are several important part of this all working.
One is putting an Extension Attribute script together to capture the information in the exported file. A simple cat /path/to/file as its result should be enough generally speaking.
Two is deploying cocoaDialog to your Macs (this could be contained in the same pkg that deploys the rest of the items)
Three is a LaunchDaemon. See below for the explanation on that.
I added a lot of notes in here on what's going on and added spaces between lines to make things a little easier to pick apart, since I'm not sure what your scripting skills are like.
You will need to create a LaunchDaemon to fire this all off. I would use a StartInterval with some number of seconds so it kicks off periodically until it runs successfully.
Couple of points on this: Launchd jobs can't run any more frequently than every 10 seconds. The OS throttles them back if they try to run any sooner and you get a bunch of entries in the system.log about it. I would choose a timeframe of maybe every 30 seconds, but of course choose whatever you feel comfortable with. Something soon enough to kick in shortly after they log in, but not so soon that it will end up tripping over itself. It has to run as a LaunchDaemon since there's a jamf recon in the script, which requires root. A LaunchAgent wouldn't be able to do that part. But since its a Daemon, it means it will run even when no-one is logged in so it compensates by detecting the owner of console and exiting if its "root" (login window)
Again, not thoroughly tested, but this should at least be a start.
#!/bin/bash
## Put full path to coocoaDialog here, wherever you deploy it to systems. Note the path all the way to the executable inside "MacOS"
CDPATH="/Library/Application Support/JAMF/cocoaDialog.app/Contents/MacOS/cocoaDialog"
## Capture the logged in user short name
loggedInUser=$( ls -l /dev/console | awk '{print $3}' )
## Get the full user name from dscl, if applicable for your environment (may need adjustment; test this separately)
fullName=$( dscl . read /Users/$loggedInUser RealName | awk -F, '{getline; print $2$1}' | sed 's/^ *//' )
## Get the computer name
compName=$( scutil --get ComputerName )
## Path to EULA file with data on disk
eulaFILE="/private/var/eula_agreement"
## Edit this text below. Note that you may need to adjust the --height integer in the cocoaDialog call to accommodate longer text
MsgText="Below is the company's End User License Agreement.
Please read it carefully, then check the "I agree" checkbox below, and finally click "OK".
Full EULA text goes here."
## Main script starts here
## See who's logged in. If its not "root" we aren't sitting at the login screen.
if [[ "$loggedInUser" != "root" ]]; then
echo "A user is logged in"
## Check to see if a eula_agreement file is already on disk, just in case it ran already
if [[ ! -e "$eulaFILE" ]]; then
echo "No previous eula_agreement file found on disk. Continuing..."
# Display the dialog. Notes:
# 1. The "--value-required" flag forces them to check the checkbox before the dialog can be dismissed.
# 2. If you want a custom icon, use --icon-file instead of --icon below and enter the full path to the icon file (icns, png, jpg, etc)
# 3. Adjustment of the --width and --height integers may be necessary. Occasionally CD doesn't rescale correctly based on the text.
# 4. Enter a title after --title if you want the dialog to have one. Use "" to use a blank title
EULADialog=$( "$CDPATH" checkbox --title "" --label "$MsgText"
--items "I agree to these terms" --button1 " OK " --value-required
--icon info --width 400 --height 220 )
## Now detect the response.
if [[ $( echo "$EULADialog" | awk 'NR>1{print $0}' ) == "1" ]]; then
echo "The dialog exited with the Agree button checked"
AgreeChecked="Yes"
## Export the settings to a file on disk that can be picked up by recon later
echo -e "EULA agreement status:
Username: $loggedInUser
Full Name: $fullName
Computer Name: $compName
User Agreed?: $AgreeChecked
Agreement Date: $(date +"%b %d, %Y, %T")" > "$eulaFILE"
## Run a recon to suck up the EULA file. You will need an Extension Attribute designed to capture the contents of this file.
echo "Gathering new inventory"
jamf recon
## If the recon was successful
if [[ "$?" == "0" ]]; then
## Now, clean up
## Unload the LaucnhDaemon that triggers the script
/bin/launchctl unload /Library/LaunchDaemons/com.nameoflaunchdamon.plist
## Delete the LaunchDaemon
/bin/rm -f "/Library/LaunchDaemon/com.nameoflaunchdaemon.plist"
## Delete the eula file
/bin/rm "$eulaFILE"
## Delete the script last
/bin/rm -f "$0"
else
echo "Recon failed. Let's not delete anything until we can capture the file. Exit until next run..."
exit 0
fi
else
echo "Somehow the 'I agree' box wasn't checked. Exit until next run..."
exit 0
fi
else
echo "An existing eula_agreement file was found. Run recon (just in case) and then delete the file..."
jamf recon
/bin/rm "$eulaFILE"
exit 0
fi
else
## If the logged in user is root, the Mac is still sitting at the login window. Exit and wait until the next run
echo "There is no logged in user. Exit until next run..."
exit 0
fi
Also for the LaunchDaemon, I recommend creating it in either LaunchControl or Lingon. You can find either ones URL in the Third party Products section here. When you make the Daemon, the ProgramArguments needs to be the full path to the script, like /private/var/scripts/scriptname.sh for example. The keys I'd add are RunAtLoad (makes it load from startup and ongoing) and StartInterval (add the seconds between each run, like 30)
Good luck and let me know if you have any questions. Hopefully its pretty self explanatory.