This script could easily be adapted to work for any postfix server, but at this moment, I dont really have the time to do it. If someone can, then please let me know at andy at andydixon.com
You run this script in this way:
repair (username) – eg: repair ajd
(where ajd is a user on the mail server)
The script is thus:
#!/bin/bash
imapUser="cyrusimap"
reconstructUser="cyrusimap"
username="$1"
userDirDest=`sudo -u ${imapUser} /usr/bin/cyrus/bin/mbpath user/$username`
echo -e "Reconstructing folder structure.."
sudo -u ${reconstructUser} /usr/bin/cyrus/bin/reconstruct -r -f user/$username
echo -e "Fixing folder permissions and ownership.."
find $userDirDest -type d -print0 | xargs -0 -n 1 chmod 0700
find $userDirDest -type d -print0 | xargs -0 -n 1 /usr/sbin/chown ${imapUser}:mail
echo -e "Fixing file permissions and ownership.."
find $userDirDest -type f -print0 | xargs -0 -n 1 chmod 0600
find $userDirDest -type f -print0 | xargs -0 -n 1 /usr/sbin/chown ${imapUser}:mail
echo "Repair Completed"