Hi gang-

I am in the middle of moving our email server from BSDI 3.0 to Mandrake 
8.2.  In order to avoid putting each user on the new machine I have a 
script to parse the BSDI password file, same as FreeBSD and convert it to 
a Linux compatible passwd and shadow file.  Script works great, but I need 
a little help creating each users home directory and then setting 
permissions.  

Once I run the script I will have my new passwd and shadow files, I would 
then need to parse through the list and create the user's home directory:
/home/$username and then set proper permissions correctly.  Any thoughts?  
Script for passwd conversion below.

Thanks,

-Scott


#!/usr/bin/perl
#
# Simple FreeBSD-to-Linux password converter
#  -- Linux must be using shadow passwords
#
# Nickolai Zeldovich, 1998
# http://kolya.net/, [EMAIL PROTECTED]
#
# Config stuff:
#
# "/etc/passwd" on a FreeBSD machine
$FREEBSD_PASSWD="./freebsd-passwd";
# "/etc/master.passwd" in a FreeBSD machine
$FREEBSD_MASTER="./freebsd-master.passwd";
# Where you want the Linux version of passwd file
$LINUX_PASSWD="./linux-passwd";
# Where you want the Linux version of shadow file
$LINUX_SHADOW="./linux-shadow";
# Go for it..
open(FM,"$FREEBSD_MASTER");
while(<FM>) {
 chop $_;
 ($user,$cryptpw,@etc)= split(/\:/);
 $pw{$user}=$cryptpw;
}
close(FM);
open(FP,"$FREEBSD_PASSWD");
open(LP,">$LINUX_PASSWD");
open(LS,">$LINUX_SHADOW");
while(<FP>) {
 chop $_;
 ($user,$star,$uid,$gid,$gecos,$home,$shell)=split(/\:/);
 print LP "$user:x:$uid:$gid:$gecos:$home:$shell\n";
 print LS "$user:$pw{$user}:10000:0:99999:7:::\n";
}
close(FP);
close(LP);
close(LS);


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to