[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Adding new users




> Hi,
> 
> We have a SAMBA test server working and are trying to create accounts
> for lots of users. We have a file, userlist.txt, exported from the
> school database, with entries in the format
> 
> user1:password:510:100:Name1 Class:/home/user1:/bin/bash
> user2:password:511:100:Name2 Class:/home/user2:/bin/bash
> 
> by running the command:
> 
> newusers /tmp/userlist.txt
> 
> we create accounts for all the new users automatically. Great so far.
> However, to make the accounts work we then have to manually copy all the
> files from /etc/skel to each users home directory. Not too bad for a few
> dozen users, but we have 2000 :(
> 
> Next, to add entries for the users in /etc/smbpasswd we have to run the
> command:
> 
> smbpasswd -a user1
> 
> and supply the password in response to the prompts - for every user
> individually :-(
> 
> Since this is Linux not Windoze there must be an easier way. Please can
> someone point us in the right direction.

Well, you can take the userlist.txt file as input for a short script or two 
along these lines:

	#!/bin/sh
	for i in `cat /tmp/userlist.txt | cut -d: -f1`
	do
		# Create the home directory
		cp -r /etc/skel /home/$i
		chown -R $i:users /home/$i

		# Add user to samba
		smbpasswd -a $i
	done

Copy that to a file, chmod 755 <file> then run <file>, and it should do 
what you want, near enough :)

What it does however I'll leave as an exercise to the reader :)

Chris...

-- 
\ Chris Johnson           \  "If not for me then, do it for yourself. If not
 \ cej [at] nccnet.co.uk        \  for then do it for the world." -- Stevie Nicks
  \ www.nccnet.co.uk/~cej/  ~-----------------------------------------+
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____


---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.