Permissions & Attributes /var/vmail recursively with dovecot

Discussion in 'Tips/Tricks/Mods' started by Loveless, Apr 11, 2017.

  1. Loveless

    Loveless Member

    Just wanted to post this little script here, it's very useful if you're migrating users' Maildirs into an ISPConfig system under /var/vmail,
    it also adds the Junk folder subscription if it wasn't already there.
    Code:
    #!/bin/sh
    
    chown vmail:vmail /var/vmail/ -R
    cd /var/vmail
    find . -type d -name Maildir -exec chmod 700 -R {} \;
    find . -type f \( -name '.sieve' -o -name '.sieve.svbin' \) -exec chmod 644 {} \;
    find . -type f \( -name 'dovecot-uidlist' -o -name 'dovecot-uidvalidity' -o -name 'dovecot.index*' -o -name 'maildirsize'  \) -exec chmod 600 {} \;
    find . -type f \( -name 'dovecot-uidvalidity.*'  \) -exec chmod 444 {} \;
    find . -type f \( -name 'subscriptions' \) -exec chmod 744 {} \;
    find . -type f \( -name 'subscriptions' \) -exec sh -c 'echo "Junk" >> "$1"' -- {} \;
    
    exit 0
    
    Save it as vmail.sh and run it.
     
    Last edited: Apr 18, 2017

Share This Page