[Inschool] Scripts

John Van Horn inschool@kalamazoolinux.org
Fri, 18 Jul 2003 01:44:12 -0400


Well... I do have a couple of reasons for wanting the text form of this
file. One is for a reference sheet for when users forget their passwords.
The other is to have a copy of the list and the script on another server to
rebuild the system in case of a meltdown.  I will have tape backup but one
can never be too careful. :)

I will create the text file as follows: (or whatever works best)

userid  password "user real name" "/home/students/"userid

I have only 245 or so students so this is not a huge task, creating the
accounts one at a time in the GUI app seems like more work, with no way to
replicate it if needed.

the useradd man pages are pretty clear, it's just feeding the text a line at
a time to it... make the account, grab the next line of text, make the next
account etc 250 times.

   John

----- Original Message -----
From: "Rusty Yonkers" <therustycook@yahoo.com>
To: <inschool@kalamazoolinux.org>
Sent: Thursday, July 17, 2003 10:39 PM
Subject: Re: [Inschool] Scripts


> The script should be really easy to create.  I can give you what the
> line of the script would be and then you could modify the data file
> that you have of the user information using sed to get it to the
> proper format. Basically you would use the useradd command with the
> appropriate information.  The line for each user would go as follows:
>
> useradd -c "Firstname Lastname" -p password username
>
> If you are going to use the same password for everyone to start then
> you would put the same word after the -p for each user, else you will
> put the appropriate password for each user after the -p.  If you are
> using RedHat then the system will automatically create a private
> group for the individual and assign it.  SuSE just adds everyone to
> group users for primary group :-(  ..... you can change that in the
> script though.
>
> The system will also create a home drive for the user, set rights to
> the drive and copy everything from /etc/skel to the users home drive.
>  The home drive will be created below /home by default.
>
> If you want to also assign group memberships you would put in a -G
> group1,group2,group3,.... for all the groups that you want to add the
> person to.
>
> When I teach Linux at Olympia I have the students write a script that
> asks all the pertinent information, verify that there are no
> duplicates, and then creates the accounts using the sudo command.  I
> have seen some really creative scripts.
>
> The biggest challenge will be to massage the text file with the users
> in it to the right format.  Sed is your answer to that.  O'Reilly has
> a great book on sed (sed stands for streaming editor).  With sed you
> can read in each line and rewrite it to the appropriate format for
> the script file.
>
> The only negative of this method is that the password will be in the
> script in clear text!  I will try to look around for a sample from
> one of my students tomorrow (my wife wants some attention now).