On di, 2006-01-31 at 14:55 +0200, Hendrik Boshoff wrote: > Hi > > I have created a file with details of 360 children to whom I want to > give access to our Edubuntu lab. It is a comma separated variable with > the following fields: > > username, full name, password, group1, group2 > > Can someone help with a script to create these users in a batch, and > give them membership of both groups? > > The passwords are based on a standard pattern including their birthday. > Not ideal, but I want to create a mailmerge letter to each containing > their particulars. They will be encouraged to choose their own password > once they have log'd on. (Is there a way to pre-expire a password?)
I use something like this for batch-adding, simply pipe the file into it: #!/bin/bash while [ 0 ]; do read LINE USER=`echo $LINE | cut -f 1 -d ,` FULLNAME=`echo $LINE | cut -f 2 -d ,` PASSWORD=`echo $LINE | cut -f 3 -d ,` GROUP1=`echo $LINE | cut -f 4 -d ,` GROUP2=`echo $LINE | cut -f 5 -d ,` if [ x"$USER" == x ]; then break; fi # Generate password CHARS="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" SALT="" for I in seq 8; do SALT=${SALT}${CHARS:$((RANDOM % ${#CHARS})):1} done # Create user echo "Adding user '$USER, $FULLNAME'" adduser --disabled-password --gecos "$FULLNAME,,," $USER usermod -p `echo $PWD | mkpasswd --salt $SALT --hash md5 --stdin` $USER adduser $USER $GROUP1 adduser $USER $GROUP2 done -- Dennis K. - Linux for human beings: http://www.ubuntu.com - Linux voor iedereen: http://www.ubuntu-nl.org
signature.asc
Description: This is a digitally signed message part
-- edubuntu-devel mailing list edubuntu-devel@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/edubuntu-devel