On Fri, Jun 09, 2006 at 05:09:13PM -0500, Craig Jackson
wrote:> Hi,
>
> I need to create a large number of users in the smbpasswd file.Is there a
way to do this without having to type passwords? I need a batch mode. Using
Samba 3.
# cat importusers.sh
#!/bin/bash
datafile=userdata
line_count=`cat $datafile | wc -l`
filesystem="/dev/sda1"
for data in `seq $line_count`
do
read data
username=`echo $data | awk -F" " '{print $1}'`
password=`echo $data | awk -F" " '{print $2}'`
/usr/sbin/adduser -m -s /bin/false -p $password $username
(echo $password; echo $password) | /usr/bin/smbpasswd -s -a $username
/usr/sbin/setquota -u $username 0 1048576 0 0 -a $filesystem
/bin/chmod 700 /home/$username
done < "$datafile"
# cat userdata
user1 password1
user2 password2
etc etc
Take out or add as necessary :)
--
Matthew Daubenspeck
http://www.oddprocess.org
Gentoo Linux 2.6.15-gentoo-r5 x86_64 Dual Core AMD Opteron(tm) Processor 165
19:13:22 up 29 days, 3:57, 1 user, load average: 0.07, 0.08, 0.08