addsysuser 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 uid (please be patient)..."
  28. uiddef=`nidump passwd / | cut -d: -f3 | sort -n | tail -n 1`
  29. uiddef=`echo $uiddef + 1 |bc`
  30. echo Creating account for $username...
  31. niutil -create / /users/$username
  32. niutil -createprop / /users/$username _writers_tim_passwd $username
  33. niutil -createprop / /users/$username realname $realname
  34. niutil -createprop / /users/$username _writers_passwd $username
  35. niutil -createprop / /users/$username uid $uiddef
  36. #niutil -createprop / /users/$username home_loc "<home_dir><url>afp://afp.server.com/Users/</url><path>$username</path></home_dir>"
  37. niutil -createprop / /users/$username gid $gid
  38. niutil -createprop / /users/$username home $homedir
  39. niutil -createprop / /users/$username name $username
  40. niutil -createprop / /users/$username passwd '*'
  41. niutil -createprop / /users/$username shell /dev/null