2005-01-05 03:46:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Original adduser 05 Feb 2002 by Jon L. Gardner
|
|
|
|
#
|
|
|
|
# Modified for Tor installer by Nick Mathewson
|
2007-06-12 23:41:38 +02:00
|
|
|
# 2007-06-12 Modified for leopard by Andrew Lewman
|
2005-08-05 00:28:40 +02:00
|
|
|
|
2005-01-05 03:46:25 +01:00
|
|
|
if [ "`whoami`" != "root" ]; then
|
|
|
|
echo "You must be root to execute this script."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ "x$3" = "x" ]; then
|
|
|
|
echo 'Usage: addsysuser <username> "<full name>" <homedir>'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
username=$1
|
|
|
|
realname=$2
|
|
|
|
homedir=$3
|
|
|
|
# GID 20 is "staff" which is the default. Change it if you want.
|
2007-06-12 23:41:38 +02:00
|
|
|
#gid=`niutil -readprop $ROOTPROP /groups/daemon gid`
|
|
|
|
gid=`dscl . -read /groups/daemon gid`
|
|
|
|
echo $gid
|
|
|
|
#if [ "x`niutil -list $ROOTPROP /users|cut -f2 -d' '|grep $username`" != "x" ]; then
|
|
|
|
if [ "x`dscl . -list /users|cut -f2 -d' '|grep $username`" != "x" ]; then
|
2005-01-05 03:46:25 +01:00
|
|
|
echo The account $username already exists.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
# home is the local path to the home directory
|
|
|
|
home=/Users/$username
|
|
|
|
# defhome is what goes into NetInfo
|
|
|
|
defhome="/Network/Servers/MyServer/Users"
|
2005-04-01 04:57:04 +02:00
|
|
|
#echo "Determining next available system uid (please be patient)..."
|
|
|
|
# Uids over 500 are for system users.
|
2007-06-12 23:41:38 +02:00
|
|
|
#uiddef=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1`
|
|
|
|
#uiddef=`echo $uiddef + 1 |bc`
|
2005-01-05 03:46:25 +01:00
|
|
|
echo Creating account for $username...
|
2007-06-12 23:41:38 +02:00
|
|
|
dscl . -create /users/$username
|
|
|
|
dscl . -create /users/$username _writers_tim_passwd $username
|
|
|
|
dscl . -create /users/$username realname $realname
|
|
|
|
dscl . -create /users/$username _writers_passwd $username
|
|
|
|
dscl . -create /users/$username gid $gid
|
|
|
|
dscl . -create /users/$username home $homedir
|
|
|
|
dscl . -create /users/$username name $username
|
|
|
|
dscl . -create /users/$username passwd '*'
|
|
|
|
dscl . -create /users/$username shell /dev/null
|