LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices


Reply
  Search this Thread
Old 10-08-2004, 07:51 PM   #1
ihssan
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Rep: Reputation: 0
adduser popusers


am switching from RedHat to Mandrake10. All went successfully, now I am switching the email server, but the challenge that I am facing is the popusers accounts, I have 300 employee, and I am wandering if there is a way or scrip that dos bulk users account and generate random passwds?

Thanks to you All
 
Old 10-09-2004, 09:14 AM   #2
Boudewijn
Member
 
Registered: Nov 2003
Location: The Netherlands
Distribution: MDK: 10,10.1,10_amd64,9.2,9.1 . Debian: sarge,woody, Gentoo (X86 amd64 Sparc)
Posts: 219

Rep: Reputation: 30
well, you might write yourself a script.

Random nr generation is fairly easy using BASH, and the rest kan be hardcoded\read from a file (usernames???).
You'll have to execute that kind of script as root
 
Old 10-12-2004, 12:54 PM   #3
ihssan
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Great, I am writing a script.

Has anyone migrate email account from RedHat to Mandrake? There are very much similar, but the way MD encrypts the password are different than RH.
 
Old 10-14-2004, 06:40 PM   #4
ihssan
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Here is a usfull scrip that worked great, I would like to share it with who wonts to createEmailAccounts.

##This script generate random passwd and output them to a text file.

<?

// Create multiple mail accounts
if (count($argv) < 3)
{
echo "Usage: php createMultipleEmailAccounts.php userListFile passwordLength\n";
exit;
}

$fileName = $argv[1];
$passwordLength = $argv[2];
$fileArr = file("$fileName");
$passwordCharacterString = "222333444555666777888999@$%^*()+ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
$passwordLength = $passwordLength;

$output = "";
foreach ($fileArr as $lineNum => $line)
{
$username = trim($line);

$password = "";
while(strlen($password) < $passwordLength)
{
$randNum = rand(0, strlen($passwordCharacterString));
$passwordChar = substr($passwordCharacterString, $randNum, 1);
$password .= $passwordChar;
}

exec("createmailaccount.exp $username $password");
$output .= "$username:$password\n";
}
echo $output;
$outputFile = fopen("userlist.txt", 'a');
fwrite($outputFile, $output);
fclose($outputFile);

?>









__________________



This script create Madir, Note you need both.


********************************************
#!/usr/bin/expect --

if { [llength $argv] < 2 } {
send_user "Usage: createmailaccount.exp username password\n"
exit
}
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]

send_user "user: $username password: $password\n"

send_user [exec /usr/sbin/adduser -g popusers -s /bin/false -m $username]
send_user [exec echo $username >> /etc/ftpusers]

send_user [exec maildirmake /home/$username/Maildir]
send_user [exec chown -R $username /home/$username/Maildir]
send_user [exec chgrp -R popusers /home/$username/Maildir]

send_user [exec echo ./Maildir/ > /home/$username/.qmail]
send_user [exec chown -R $username /home/$username/.qmail]
send_user [exec chgrp -R popusers /home/$username/.qmail]

spawn passwd $username

set send_slow {1 .02}
expect {
timeout { send_error "Timed out waiting for password 1."; exit 1; }
"New UNIX password: " { sleep 0.3; send -s "$password\r"; }
}

expect {
timeout { send_error "Timed out waiting for password. 2"; exit 1; }
"assword: " { sleep 0.3; send -s "$password\r"; }
}

expect {
timeout { send_error "Timed out waiting for successfully"; exit 1; }
"successfully"
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adduser jp_ Linux - General 6 10-18-2005 02:11 PM
adduser bally Linux - General 7 08-09-2004 01:28 PM
adduser trophy Red Hat 1 05-01-2004 09:11 AM
adduser teqno Linux - Newbie 5 12-08-2003 12:26 PM
Adduser - xmdms Linux - Newbie 3 10-23-2003 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration