Last active
September 4, 2018 14:07
-
-
Save jmahlman/0751c69b07eaad9061172abb32c20b5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| JAMFBIN=$(/usr/bin/which jamf) | |
| CURRENTUSER=$(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 + "\n");') | |
| # Install DEPNotify first (set this up in your jamf server of course) | |
| $JAMFBIN policy -event install_depnotify | |
| DNLOG=/var/tmp/depnotify.log | |
| # Setup DEPNotify | |
| echo "Command: MainTitle: Preparing Device for Deployment" >> $DNLOG | |
| echo "Status: Installing some stuff..." >> $DNLOG | |
| #Open DepNotify | |
| sudo -u "$CURRENTUSER" /var/tmp/DEPNotify.app/Contents/MacOS/DEPNotify & | |
| # Do the things! | |
| echo "Status: Doin' the things..." >> $DNLOG | |
| $JAMFBIN policy -event some-policy | |
| echo "Status: Doin' more things..." >> $DNLOG | |
| $JAMFBIN policy -event another-policy | |
| echo "Command: RestartNow:" >> $DNLOG | |
| # Remove DEPNotify and the logs | |
| rm -Rf /var/tmp/DEPNotify.app | |
| rm -Rf $DNLOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment