addsysuser 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. #
  3. # Original adduser 05 Feb 2002 by Jon L. Gardner
  4. #
  5. # Modified for Tor installer by Nick Mathewson
  6. if [ "`whoami`" != "root" ]; then
  7. echo "You must be root to execute this script."
  8. exit
  9. fi
  10. if [ "x$3" = "x" ]; then
  11. echo 'Usage: addsysuser <username> "<full name>" <homedir>'
  12. exit 0
  13. fi
  14. username=$1
  15. realname=$2
  16. homedir=$3
  17. # GID 20 is "staff" which is the default. Change it if you want.
  18. gid=`niutil -readprop / /groups/daemon gid`
  19. if [ "x`niutil -list / /users|cut -f2 -d' '|grep $username`" != "x" ]; then
  20. echo The account $username already exists.
  21. exit 0
  22. fi
  23. # home is the local path to the home directory
  24. home=/Users/$username
  25. # defhome is what goes into NetInfo
  26. defhome="/Network/Servers/MyServer/Users"
  27. #echo "Determining next available system uid (please be patient)..."
  28. # Uids over 500 are for system users.
  29. uiddef=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1`
  30. uiddef=`echo $uiddef + 1 |bc`
  31. echo Creating account for $username...
  32. niutil -create / /users/$username
  33. niutil -createprop / /users/$username _writers_tim_passwd $username
  34. niutil -createprop / /users/$username realname $realname
  35. niutil -createprop / /users/$username _writers_passwd $username
  36. niutil -createprop / /users/$username uid $uiddef
  37. #niutil -createprop / /users/$username home_loc "<home_dir><url>afp://afp.server.com/Users/</url><path>$username</path></home_dir>"
  38. niutil -createprop / /users/$username gid $gid
  39. niutil -createprop / /users/$username home $homedir
  40. niutil -createprop / /users/$username name $username
  41. niutil -createprop / /users/$username passwd '*'
  42. niutil -createprop / /users/$username shell /dev/null