Skip to content

Instantly share code, notes, and snippets.

@jonmannn
Created July 12, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonmannn/75496c3813a67c67c3e28f8dcfa06725 to your computer and use it in GitHub Desktop.
Save jonmannn/75496c3813a67c67c3e28f8dcfa06725 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get username of current logged in user
# This method breaks if you allow multiple accounts logged in.
USERNAME=$(ls -l /dev/console | awk '{print $3}')
membership=$(dsmemberutil checkmembership -U $USERNAME -G admin)
if [ "$membership" == "user is not a member of the group" ];
then
if ! launchctl list|grep -q com.apple.atrun; then launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist; fi
/usr/sbin/dseditgroup -o edit -a $USERNAME -t user admin
echo dseditgroup -o edit -d $USERNAME -t user admin|at now +2 minutes &>/dev/null
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -title "Self Service" -heading "You're now an admin. Go, go, go!" -button1 "Ok"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment