LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   adding 276 users (https://www.linuxquestions.org/questions/debian-26/adding-276-users-72030/)

k1e0x 07-11-2003 09:26 PM

adding 276 users
 
Ok I was able to convince my staff to replace there old exchange server with a Debian mail server. I have it up and running now and all is well, however I still need to add alot of users to the system before we switch over. I have now a execell spreadsheat that looks somewhat like this.

user1 pass1
user2 pass2
etc..

if I export that to a txt file. what is the easiest way to add those to the system? perl script maybe? is there a speical "Debian" way to go about it? what about adding user quotas, should I even worry about quotas?

thanks in advance.

isme 07-12-2003 10:34 AM

you can make a shellscript to create the accounts.
here are some hints:

addgroup $user : to add the group
useradd -d /home/$user -g $user -m $user : to add the users, create home directories etc.
echo "$user:$password" | chpasswd : to make the passwords.

Of course, you need to script this a littlebit, to read $user and $password from your txt file.

Hope, that helps.

k1e0x 07-12-2003 01:21 PM

yeah, thats likley what ill do. I was just wondering if there was a more Debian centric approach to it, like kernel-package or the pentium-builder types of packages..

or better yet sync it to a active directory server, that would be my ultimate solution.

k1e0x 08-07-2003 04:29 PM

here is the script I used to do this, I thought I would share it so other people didn't have to go through the trouble I did making it.

(the forum may eat the script's syntax)

#!/usr/bin/perl
# addusers script to be used on a SQL user database
# works with windows carrage returns ("^M")
# password,Lastname,Firstname

for $line (<>) {

# get password
$pw_end=index($line,",");
$pwd=substr($line,0,$pw_end);

# get lastname
$lname_start=index(($line,","))+1;
$lname_end=index($line,",",$lname_start);
$lname_width=$lname_end-$lname_start;
$lname=substr($line,$lname_start,$lname_width);

# get firstname
$fname_start=index($line,",",$lname_end)+1;
$fname=substr($line,$fname_start,(chomp($fname_start)+1));

$user=substr($fname,0,1).$lname;
$user="\L$user";

# build bash command
# UNHASH BELOW LINE TO MAKE SCRIPT LIVE
#system "bash command";

}
print "\nDone!\n";


All times are GMT -5. The time now is 05:28 PM.