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
7 # Copyright (c) 2007 Andrew Lewman
13 if [ "`whoami`" != "root" ]; then
14 echo "You must be root to execute this script."
17 if [ "x$3" = "x" ]; then
18 echo 'Usage: addsysuser <username> "<full name>" <homedir>'
24 if [ -x /usr
/bin
/dscl
]; then
25 # Determine the gid of the daemon group
26 gid
=`dscl . -read /groups/daemon gid`
27 if [ "x`dscl . -list /users|cut -f2 -d' '|grep $username`" != "x" ]; then
28 echo The account
$username already exists.
31 # home is the local path to the home directory
33 echo Creating account
for $username...
34 dscl .
-create /users
/$username
35 dscl .
-create /users
/$username _writers_tim_passwd
$username
36 dscl .
-create /users
/$username realname
$realname
37 dscl .
-create /users
/$username _writers_passwd
$username
38 dscl .
-create /users
/$username gid
$gid
39 dscl .
-create /users
/$username home
$homedir
40 dscl .
-create /users
/$username name
$username
41 dscl .
-create /users
/$username passwd
'*'
42 dscl .
-create /users
/$username shell
/dev
/null
44 # Determine the gid of the daemon group
45 gid
=`niutil -readprop $ROOTPROP /groups/daemon gid`
46 if [ "x`niutil -list $ROOTPROP /users|cut -f2 -d' '|grep $username`" != "x" ]; then
47 echo The account
$username already exists.
50 # home is the local path to the home directory
52 # defhome is what goes into NetInfo
53 defhome
="/Network/Servers/MyServer/Users"
54 #echo "Determining next available system uid (please be patient)..."
55 # Uids over 500 are for system users.
56 uiddef
=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1`
57 uiddef
=`echo $uiddef + 1 |bc`
58 echo Creating account
for $username...
59 niutil
-create $ROOTPROP /users
/$username
60 niutil
-createprop $ROOTPROP /users
/$username _writers_tim_passwd
$username
61 niutil
-createprop $ROOTPROP /users
/$username realname
$realname
62 niutil
-createprop $ROOTPROP /users
/$username _writers_passwd
$username
63 niutil
-createprop $ROOTPROP /users
/$username uid
$uiddef
64 #niutil -createprop $ROOTPROP /users/$username home_loc "<home_dir><url>afp://afp.server.com/Users/</url><path>$username</path></home_dir>"
65 niutil
-createprop $ROOTPROP /users
/$username gid
$gid
66 niutil
-createprop $ROOTPROP /users
/$username home
$homedir
67 niutil
-createprop $ROOTPROP /users
/$username name
$username
68 niutil
-createprop $ROOTPROP /users
/$username passwd
'*'
69 niutil
-createprop $ROOTPROP /users
/$username shell
/dev
/null