December 15, 2007

I’ve updated useradd to support both Tiger and Leopard. Many thanks go to Allan Sanderson for his Leopard changes and bringing the need for an update to my attention in the first place!

There are some other improvements as well, including checking if the user already exists, cloning the non-localized bits from the User Template and semi-random, dictionary-based default passwords.

I’ve tested the script on 10.4.10 and 10.5.1.

Some remarks:

  • An easy way to target specific OS X versions:
os_ver=$(sysctl -n kern.osrelease)
if [ $os_ver -lt 9 ]
  then # something Tiger specific...
  • What’s up with those group name underscores in Leopard? Apple says to create them when running into migration trouble. OS X doesn’t create them for new accounts automatically. It can’t be just a migration thing since almost all system-level accounts have them also. If You have an explanation for that, don’t hesitate to leave a comment.

  • ni-anything, including nireport are gone in .5 so use dscl