Well, what I ended up doing was booting into single user mode and editing the /etc/sudoers file (using /usr/sbin/visudo) to contain a line explicitly giving greg sudo privileges via greg ALL=(ALL) ALL. Then, after rebooting, I ran sudo niutil -createprop /groups/admin users root greg, and everything was rosy again. Note that the standard sudoers file contains entries for root and for %admin, meaning members of the admin group. This explains why both admin status and sudo capability went away as a result of the runaway script.
Putting an explicit name into the sudoers file saved the day for me, maybe it'll help someone else someday.
Update from robg: Please see the attached comments for a revised adduser script that doesn't cause these issues, and thanks to Cap'n Hector for submitting it!

