On Jun 8, 2005, at 7:31 AM, Uwe Dippel wrote:

What I'd want, is to check the passwd file and delete all home dirs that
have no user account any longer.
Then, I'd also create home dirs for all users in the passwd without home
dir yet.
Since this is a migration of > 100 users from Linux, I don't feel like
doing it manually and the FAQ stops at importing the accounts.
Getting the list of the users on Linux doesn't help, there are about 100
home dirs for archive reasons; without valid accounts.
So I'd actually need an auto-creation of home dirs for active accounts
from an OpenBSD passwd file. Plus, I don't need the _ and < 1000.

The simple answer:

Create your user accounts (there is a FAQ for migrating SysV/Linux to master.passwd/BSD). I also have a very poorly written Perl script which will generate the useradds for you:

Clean up your source password list (from the Linux box) before generating the useradds, so only active accounts will be added to the new system.

http://bda.mirrorshades.net/code/scripts/openbsd/bin/migrate_users.pl

cd /home
for i in * ; do rsync $source:/home/$i . ; chown -R $i:$i $i ; done

Go go gadget shell.

If you've already added the users, but there were no original accounts on the new host, you can just rsync /home with the --delete option and it'll clean the tree for you.

If you're merging systems, and have overlapping usernames, or homedirs that existed on the other system or are otherwise desync'd, you'll have to write some conditions or whatever.

I've migrated probably half a dozen boxes since I started using OpenBSD heavily (moving away from Linux) last year. I have yet to run into any major problems.

I haven't been sleeping well lately, so the world has gone a bit sideways. Take the above with a shaker or two of salt.

As for maintaining state between the password files and /home (and conceivably the mailspools) I can think of a few simple ways to do it with Perl, but never bothered. I always archived and moved the user's homedir off (or deleted it) when the user's status was changed.

Cheers.
--
bda
cyberpunk is dead. long live cyberpunk.

Reply via email to