#!/bin/sh # Pay attention!!! This isn't meant for a complete rewrite of the Linux # passwd file!!! You should keep your mission-critical entries in the # BSD passwd file (like root, wheel, etc.), and replace only those # non-critical, like the domain names which have an account. This is because # this script changes the UIDs, GIDs of the users by default. Of course, # with a little hacking, you could do it make a complete exporting. # DOn't forget to run 'pwd_mkdb' after you have exported the files. linux_passwd_file=$1 linux_shadow_file=$2 bsd_passwd_file=$3 bsd_master_file=$4 if [ -z "$1" ] then error=1 fi if [ -z "$2" ] then error=1 fi if [ -z "$3" ] then error=1 fi if [ -z "$4" ] then error=1 fi if [ "$error" -eq "1" ] then echo "" echo " Usage: $0 Linux_passwd Linux_shadow BSD_passwd BSD_master" echo " Where: " echo " - Linux_passwd is the Linux passwd file" echo " - Linux_shadow is the Linux shadow file" echo " - BSD_passwd is the BSD passwd file (will be created/overwritten)" echo " - BSD_master is the BSD master file (will be created/overwritten)" echo "" echo " I will not assume any responsability for any harm this script will do on your system" echo "" exit fi # I define only one general GID for all the domains. group_id=5000 user_name=`cat $linux_passwd_file | cut -f 1 -d ":"` j=0 for i in $user_name do j=$(($j + 1)) user_id=$j one_line_passwd=`cat $linux_passwd_file | grep "$i:" | head -n 1` full_user_name=`echo $one_line_passwd | cut -f 5 -d ":"` user_name_without_TLD=`echo $i | cut -f 1 -d "."` home_directory=`echo $one_line_passwd | cut -f 6 -d ":"` default_shell=`echo $one_line_passwd | cut -f 7 -d ":"` one_line_shadow=`cat $linux_shadow_file | grep "$i:" | head -n 1` password=`echo $one_line_shadow | cut -f 2 -d ":"` #if [ "$password" = "*" ] # then # password="!" #fi # Now I'm creating the password file in BSD format (master.passwd) echo $user_name_without_TLD:$password:$user_id:$group_id::0:0:$full_user_name:$home_directory:$default_shell >> $bsd_master_file # And now I'm creating the password file in plain Unix passwd format (w/o passwords in it) echo $user_name_without_TLD:\*:$user_id:$group_id:$full_user_name:$home_directory:$default_shell >> $bsd_passwd_file done