Last active
September 4, 2018 14:08
-
-
Save jmahlman/a6bb24378019b8a2a75553b06d7d7099 to your computer and use it in GitHub Desktop.
This file contains 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 prefs and starting GUI | |
# where to drop the plist after input | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify PathToPlistFile /var/tmp/ | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify RegisterMainTitle "Assignment..." | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify RegistrationButtonLabel Assign | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify UITextFieldUpperLabel "Assigned User" | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify UITextFieldUpperPlaceholder "dadams" | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify UITextFieldLowerLabel "Asset Tag" | |
sudo -u "$CURRENTUSER" defaults write menu.nomad.DEPNotify UITextFieldLowerPlaceholder "UA42LAP1337" | |
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 | |
# call the user input dropdown | |
echo "Command: ContinueButtonRegister: Assign" >> $DNLOG | |
# We have the plist...now what? | |
# We'll quit the app after we're done...but something is wrong.. | |
echo "Command: Quit: Done!" >> $DNLOG | |
# Remove DEPNotify and the logs | |
rm -Rf /var/tmp/DEPNotify.app | |
rm -Rf $DNLOG | |
rm -Rf $DNPLIST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment