View Single Post
Old 29th November 2006, 20:06
rojozak rojozak is offline
Junior Member
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 2 Times in 1 Post

Hi...Yes, I've been using the script for about a week now and it is working nicely. A few things to note however:

1. Jwan is correct, there is a typo in the original post and it is supposed to be pw2userdb rather than pw2userdb2.

2. The script that builds userdb didn't work for me. I had to modify it some. There were some errors (possibly from the HTML copy) and I had to modify the cut command lines as it was not building my userdb file to proper format. (The uid was not truncating properly, if i recall correctly). I've posted the script that I rewrote below. This has been working great for me on my system.

3. Of course, any users you currently have prior to the switch with the [domain]_ tag will need to be removed and readded (or modified, i suppose if you want to mess with that) in order for them to be able to work with this system. Luckily I had a clean install with only test users before I loaded this and added users for production.

Thanks again for your work desmonddk.

Here's my script:



rm -rf /etc/courier/userdb
touch /etc/courier/userdb
chmod 600 /etc/courier/userdb

for line in `pw2userdb | grep -ir user`
        full=$( echo $line )
        domain=$( echo $line | cut -d"$delim" -f1 )
        remain=$( echo $line | cut -d"$delim" -f2,3,4 )
        username=$( echo $remain | cut -d'      ' -f1 )
        remain2=$( echo $remain | cut -d'       ' -f2 )
        uid=$( echo $remain2 | cut -d'|' -f1 )
        gid=$( echo $remain2 | cut -d'|' -f2 )
        home=$( echo $remain2 | cut -d'|' -f3 )
        shell=$( echo $remain2 | cut -d'|' -f4 )
        password=$( echo $remain2 | cut -d'|' -f5)
        echo "$username@$domain $uid|$gid|$home|$shell|$password|/var/www/www.$domain/user/${domain}_$username/Maildir" >> /$

Reply With Quote