Subject: Re: script to add users
To: None <netbsd-help@netbsd.org>
From: Chris Wareham <chris.wareham@iosystems.co.uk>
List: netbsd-help
Date: 12/03/2002 10:04:55
Carlo Smith wrote:
> Hi,
> 
> looking for a script to add users including homedirs, it also needs to 
> check if the user already exist.
> 
> Thanks !
> 

Hmm, well using the correct arguments to useradd should do what you
want. If all you want to do is check the existence of a user before
running useradd then something as trivial as the following should
suffice:

if [ -d /home/$userarg ]; then
     echo "/home/$userarg already exists"
     exit 1;
fi

If the directory doesn't exist, then just run useradd with the "-m"
argument to create a home directory.

Chris
-- 
chris.wareham@iosystems.co.uk (work)
chris.wareham@btopenworld.com (home)