> I'm much more familiar with Linux, normally I would user adduser
> without a home directory, but there is no adduser/useradd on Darwin
> that I can tell.
There isn't, but you can roll your own using dscl and a shell script. This
is one I use to create FTP users on an OS X client box, but it should be
enough to give you the idea. I've tried to mark inappropriate linebreaks
with \ but use due diligence. Anybody who wishes to mock my scripting
abilities is probably justified. There is no warranty express or implied or
even hinted at. Do NOT taunt the monkeys. Pregnant women should not use this
script while rollerblading. Nous sommes desoles que notre president soit un
idiot.
=====
#!/bin/sh
LongName=$1
ShortName=$2
UserPassword=$3
declare -i u=1999
read u < /var/tmp/FTPlastUIDused
#declare UIDCheck=1
if [ -n "$4" ]; then
echo "Usage:"
echo "CreateFTPClient Long_Name shortname password"
echo ""
echo "(Three shall be the number of the arguments, and the"
echo "number of the arguments shall be three. Four shalt thou"
echo "not count, and neither count thou two excepting that"
echo "thou then goest on to three. Five is right out.)"
exit 1
fi
if [ -z "$3" ]; then
echo "Usage: CreateFTPClient Long_Name shortname password"
echo ""
echo "(Three shall be the number of the arguments, and the"
echo "number of the arguments shall be three. Four shalt thou"
echo "not count, and neither count thou two excepting that"
echo "thou then goest on to three. Five is right out.)"
exit 1
fi
SearchShort=`dscl localhost -search /NetInfo/root/Users \
dsAttrTypeStandard:RecordName $ShortName`
if [ -n "$SearchShort" ]; then
echo "Short name already exists, aborting."
fi
SearchLong=`dscl localhost -search /NetInfo/root/Users \
dsAttrTypeStandard:RealName $LongName`
if [ -n "$SearchLong" ]; then
echo "Long name already exists, aborting."
fi
UserHash=`openssl passwd -crypt -salt Q3 $UserPassword`
echo "Assigning unique UID..."
#until [ -z "$UIDcheck" ]; do
u=$u+1
# UIDcheck=`dscl localhost -search /NetInfo/root/Users uid $u | grep \
-v "Search results for dsAttrType"`
#done
echo "UID assigned:" $u
echo $u > /var/tmp/FTPlastUIDused
echo "Checking home directory..."
if [ ! -e /Volumes/Files/FTPShare/$LongName ]; then
mkdir /Volumes/Files/FTPShare/$LongName
echo "Home directory created."
else
echo "Home directory already exists, continuing..."
fi
echo "Creating user..."
dscl . -create /Users/$ShortName
dscl . -create /Users/$ShortName uid $u
dscl . -create /Users/$ShortName gid 20
dscl . -create /Users/$ShortName shell /bin/tcsh
dscl . -create /Users/$ShortName home /Volumes/Files/FTPShare/$LongName
dscl . -create /Users/$ShortName passwd "$UserHash"
echo "Done."
echo "Setting permissions..."
chmod 770 /Volumes/Files/FTPShare/$LongName
chown $u:499 /Volumes/Files/FTPShare/$LongName
echo $ShortName >> /etc/ftpchroot
if [ -e /var/tmp/FTPUserEmail ]; then
rm /var/tmp/FTPUserEmail
fi
# compose email notification
echo "A new FTP user has been created." >> /var/tmp/FTPUserEmail
echo "" >> /var/tmp/FTPUserEmail
echo "Client name: " $LongName >> /var/tmp/FTPUserEmail
echo "Username: " $ShortName >> /var/tmp/FTPUserEmail
echo "Password: " $UserPassword >> /var/tmp/FTPUserEmail
</var/tmp/FTPUserEmail mail -s "A new FTP user has been created." \
[EMAIL PROTECTED]
echo "All done."
=====
--
Dave Pooser
Cat-Herder-in-Chief, Pooserville.com
"...Life is not a journey to the grave with the intention of arriving
safely in one pretty and well-preserved piece, but to slide across the
finish line broadside, thoroughly used up, worn out, leaking oil, and
shouting GERONIMO!!!" -- Bill McKenna
R.I.P. Charles "Socks the Whitehouse Cat" Oriez, 1952-2005
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[email protected]>.
To unsubscribe, E-mail to: <[EMAIL PROTECTED]>
To switch to the DIGEST mode, E-mail to <[EMAIL PROTECTED]>
To switch to the INDEX mode, E-mail to <[EMAIL PROTECTED]>
Send administrative queries to <[EMAIL PROTECTED]>