2 # Upgrading script to AlternC 1.1
4 CONFIG_FILE="/etc/alternc/local.sh"
5 PATH=/sbin:/bin:/usr/sbin:/usr/bin
9 if [ ! -r "$CONFIG_FILE" ]; then
10 echo "Can't access $CONFIG_FILE."
14 if [ `id -u` -ne 0 ]; then
15 echo "3.0.0~2.sh must be launched as root"
21 MAIL_DIR="$ALTERNC_LOC/mail"
23 ## This part update mails' file owner and group ##
25 read LOGIN GID || true
26 while [ "$LOGIN" ]; do
27 INITIALE=`echo $LOGIN |cut -c1`
28 MAIL=$(echo $LOGIN |sed -e 's/\@/_/')
29 REP="$ALTERNC_LOC/mail/$INITIALE/$MAIL/"
30 chown --recursive $GID:vmail "$REP"
31 read LOGIN GID || true
35 query="select user,userdb_gid from dovecot_view"
36 mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |fix_mail
37 ## End of mails' files owner and group fixing part ##
39 ## This part does the migration from Courier IMAP and POP3, preserving IMAP UIDs and POP3 UIDLs. ##
40 ## It reads Courier's 'courierimapuiddb' and 'courierpop3dsizelist' files and produces 'dovecot-uidlist' file from it. ##
41 # We warn user it will take some time to migrate all indexes
43 echo "################################################"
44 echo "# /!\ CONVERTING COURIER INDEXES TO DOVECOT /!\ "
45 echo "# /!\ THIS MAY TAKE A WHILE ! /!\ "
47 echo "# If you want to regenerate specifics indexes, "
48 echo "# remove related 'dovecot-uidlist' files in "
50 echo "# then execute this command manually : "
52 echo "# perl \"/usr/lib/alternc/courier-dovecot-migrate.pl\" --to-dovecot --convert --recursive \"$MAIL_DIR\""
54 echo "# Add \"--overwrite\" option if you want to "
55 echo "# overwrite ALL 'dovecot-uidlist' indexes "
56 echo "################################################"
60 # Stoping dovecot service
61 invoke-rc.d dovecot stop || true
63 # We call the migration script (provided by wiki.dovecot.com)
64 perl "/usr/lib/alternc/courier-dovecot-migrate.pl" --to-dovecot --convert --recursive "$MAIL_DIR"
67 #We have to resync maildirs quotas with dovecot informations.
68 /usr/lib/alternc/update_quota_mail.sh
70 # Starting dovecot service
71 invoke-rc.d dovecot start || true
72 ## End of migration part