At 12:55 PM 9/4/2002 -0700, Gordon Messmer wrote: >On Wed, 2002-09-04 at 12:49, Scott wrote: > > I am in the middle of moving users from a BSDI (FreeBSD) machine to a > > new Red Hat 7.3 server that will serve as a Postfix box. > > > > I have a script to parse the FreeBSD passwd file and convert it to Linux > > compatible > > passwd and shdow files, but I am looking for a way to take those user > names and > > create their home directories and then set permissions. Any thoughts? > >After you convert the password files: > >grep /home/ /etc/passwd | awk -F: '{ print $3 " " $4 " " $6; }' \ > | while read pwuid pwgid pwhome ; do > [ -d $pwhome ] || ( mkdir $pwhome && chown $pwuid:$pwgid $pwhome ) > done
Well, no. You *don't* want "home" directories for nobody, root, daemon, etc. A simple one would be, first, only convert the system users, and then, from the old passwd file: awk "BEGIN { FS = ":"; } \ {if ( $3 > 100 && $3 < 64000 ) { \ group = $4; \ added_groups = "-G whatever"; \ uid_if_you_want = $3; \ cmd = "useradd -g " group " added_groups " -m -shell /usr/bash " \ uid_if_you_want " " $6;\ system (cmd);}}" old_passwd; There. This starts in the BEGIN by telling awk that the field separator is ":", so it can parse the password file, then gets all non-system UIDs (65k is nfsnobody), creates a command, and uses the system command to run useradd, which will make create the users, make the home directories, make sure that they have the right permissions, and the right shell, etc. mark -- Ashcroft - guilty of statutory drape, for spending $8,000 of taxpayer money to cover the bare aluminum breast of the statue of Justice. -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list