Skip to content

Instantly share code, notes, and snippets.

@mounty1
Created May 12, 2022 01:37
Show Gist options
  • Select an option

  • Save mounty1/88c6c09a1e3bd97b013621dccb9c16d4 to your computer and use it in GitHub Desktop.

Select an option

Save mounty1/88c6c09a1e3bd97b013621dccb9c16d4 to your computer and use it in GitHub Desktop.
# Copy and convert a Dovecot maildir hierarchy to Cyrus.
# Nothing wrong with Dovecot but my OS (OmniOS) does not maintain it in the package repo.
# Run it in the root of the Dovecot store.
for user in *
do
droot=/var/opt/ooce/cyrus/mail/${user:0:1}/user/${user}/
ls -d ${user}/.[1-z]*/cur | sed -e 's:^'"${user}"'/\.\(.*\)/cur:\1:' | while read D
do
dest="${droot}${D//\./\/}"
echo "<<<${dest}>>>"
sudo -u cyrus mkdir -p -m 700 "${dest}"
echo "" | ls "${user}/.${D}/cur" | nl -ba | sed 's:^ *\(.*\) \(.*\)$:cp "'"${user}/.${D}"'/cur/\2" "'"${dest}"'/\1.":' | sh
sudo -u cyrus touch "${dest}"/cyrus.header
chown cyrus:cyrus "${dest}"/*. ; chmod 644 "${dest}"/*.
done
done
reconstruct -q -x -f -R -G -M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment