Raymond Norton wrote:
> I'm moving all user info over to a new server
> (passwd-group-gshadow-shadow /home, and /var/spool/mail).
>
> I'm forgetting how to merge the user name and password info so as not
> to overwrite anything on the new server, or cause conflicts with user
> ids, etc...
>
>
>
>
Thought I found the perfect answer this morning. I ran the script below,
and everything seemed to merge fine. Homes and /var/spool/mail/ all
seemed to have the correct permissions. I installed squirrelmail,
attempted to login as one of the users, but no go, so I attempted to run
"passwd username", but got an error saying the user did not exist. I
double checked /etc/passwd, and the user is there. What else should I be
looking for to fix this?
The new box is Ubuntu, Intrepid.
Script and commands:
<script>
#!/usr/bin/perl
use warnings;
use strict;
use Tie::File::AsHash;
die "usage:$0 <oldfile> <newfile>\n" if @ARGV ne 2;
my ($old, $new) = @ARGV;
die "$new: $!" if ! -f $new;
tie my %new, 'Tie::File::AsHash', $new, split => ':'
or die "Problem tying %new: $!";
open (OLD, $old) || die "can't read $old $!";
while(<OLD>) {
chomp;
my ($uid) = $_ =~ /^([^:]+)/;
$new{$uid} = $_ if ! $new{$uid};
}
close OLD;
untie %new;
</script>
./merge.pl /root/passwd /etc/passwd
./merge.pl /root/shadow /etc/shadow
./merge.pl /root/group /etc/group
./merge.pl /root/gshadow /etc/gsjhadow