3 # Original adduser 05 Feb 2002 by Jon L. Gardner
5 # Modified for Tor installer by Nick Mathewson
6 # 2007-06-12 Modified for leopard by Andrew Lewman
11 if [ "`whoami`" != "root" ]; then
12 echo "You must be root to execute this script."
15 if [ "x$3" = "x" ]; then
16 echo 'Usage: addsysuser <username> "<full name>" <homedir>'
22 if [ -x /usr
/bin
/dscl
]; then
23 # Determine the gid of the daemon group
24 gid
=`dscl . -read /groups/daemon gid`
25 if [ "x`dscl . -list /users|cut -f2 -d' '|grep $username`" != "x" ]; then
26 echo The account
$username already exists.
29 # home is the local path to the home directory
31 echo Creating account
for $username...
32 dscl .
-create /users
/$username
33 dscl .
-create /users
/$username _writers_tim_passwd
$username
34 dscl .
-create /users
/$username realname
$realname
35 dscl .
-create /users
/$username _writers_passwd
$username
36 dscl .
-create /users
/$username gid
$gid
37 dscl .
-create /users
/$username home
$homedir
38 dscl .
-create /users
/$username name
$username
39 dscl .
-create /users
/$username passwd
'*'
40 dscl .
-create /users
/$username shell
/dev
/null
42 # Determine the gid of the daemon group
43 gid
=`niutil -readprop $ROOTPROP /groups/daemon gid`
44 if [ "x`niutil -list $ROOTPROP /users|cut -f2 -d' '|grep $username`" != "x" ]; then
45 echo The account
$username already exists.
48 # home is the local path to the home directory
50 # defhome is what goes into NetInfo
51 defhome
="/Network/Servers/MyServer/Users"
52 #echo "Determining next available system uid (please be patient)..."
53 # Uids over 500 are for system users.
54 uiddef
=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1`
55 uiddef
=`echo $uiddef + 1 |bc`
56 echo Creating account
for $username...
57 niutil
-create $ROOTPROP /users
/$username
58 niutil
-createprop $ROOTPROP /users
/$username _writers_tim_passwd
$username
59 niutil
-createprop $ROOTPROP /users
/$username realname
$realname
60 niutil
-createprop $ROOTPROP /users
/$username _writers_passwd
$username
61 niutil
-createprop $ROOTPROP /users
/$username uid
$uiddef
62 #niutil -createprop $ROOTPROP /users/$username home_loc "<home_dir><url>afp://afp.server.com/Users/</url><path>$username</path></home_dir>"
63 niutil
-createprop $ROOTPROP /users
/$username gid
$gid
64 niutil
-createprop $ROOTPROP /users
/$username home
$homedir
65 niutil
-createprop $ROOTPROP /users
/$username name
$username
66 niutil
-createprop $ROOTPROP /users
/$username passwd
'*'
67 niutil
-createprop $ROOTPROP /users
/$username shell
/dev
/null