I hate being such a script noob. I feel like I'm really close but am missing some critical piece of information in order to get this script to work. This script is intended to get the name of the current user and then make that user an admin, or make them a standard user, depending on whether I have the -d or -a in there.
I can get the first line to return the user name on its own, and I can get the second line to set or remove the user as an admin as long as I put the name in rather than using a variable, so I know I'm close. I just can't get the two lines to work together, i.e. to get the first line to grab the username, set it as the "userName" variable, and pass it to the second line via $userName.
#!/bin/sh
userName=ls -l /dev/console | awk '{ print $3 }'
sudo dseditgroup -o edit -a $userName -t user admin
Searching for how to create functional variables hasn't turned up anything relatable to what I'm doing here. Anybody have some pointers on how to make this work?