All the controller things want their stuff in v2 format. Well then, maybe that's...
[tor/rransom.git] / contrib / polipo / addsysuser
blob7b167eac004c4415460d47a30c0fddb4233cb496
1 #!/bin/sh
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
9 ROOTPROP=/
11 if [ "`whoami`" != "root" ]; then
12 echo "You must be root to execute this script."
13 exit
15 if [ "x$3" = "x" ]; then
16 echo 'Usage: addsysuser <username> "<full name>" <homedir>'
17 exit 0
19 username=$1
20 realname=$2
21 homedir=$3
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.
27 exit 0
29 # home is the local path to the home directory
30 home=/Users/$username
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
41 else
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.
46 exit 0
48 # home is the local path to the home directory
49 home=/Users/$username
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