Adding a script to resync maildirs quotas used by dovecot with AlternC 3
This commit is contained in:
parent
6acdb33c77
commit
06bc5abf34
|
@ -610,6 +610,7 @@ src/spoolsize.php -text
|
|||
src/sqlbackup.sh -text
|
||||
src/update_domains.sh -text
|
||||
src/update_mails.sh -text
|
||||
src/update_quota_mail.sh -text
|
||||
/svnup.sh -text
|
||||
tests/make_mail_dataset.sh -text
|
||||
tests/mechdump.pm -text
|
||||
|
|
|
@ -62,6 +62,10 @@ invoke-rc.d dovecot stop || true
|
|||
# We call the migration script (provided by wiki.dovecot.com)
|
||||
perl "/usr/lib/alternc/courier-dovecot-migrate.pl" --to-dovecot --convert --recursive "$MAIL_DIR"
|
||||
|
||||
|
||||
#We have to resync maildirs quotas with dovecot informations.
|
||||
/usr/lib/alternc/update_quota_mail.sh
|
||||
|
||||
# Starting dovecot service
|
||||
invoke-rc.d dovecot start || true
|
||||
## End of migration part
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
# ----------------------------------------------------------------------
|
||||
# Purpose of file: Makefile des binaires de /usr/lib/alternc
|
||||
# ----------------------------------------------------------------------
|
||||
SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh alternc_add_policy_dovecot rebuild_all_webconf.sh courier-dovecot-migrate.pl popimap-log-login.sh mem_add mem_del quota_edit quota_get du.pl
|
||||
SCRIPTS=sqlbackup.sh quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php cron_users_doit.sh cron_users.sh compress_logs.sh delete_logs.sh quota-warning.sh update_mails.sh alternc_add_policy_dovecot rebuild_all_webconf.sh courier-dovecot-migrate.pl popimap-log-login.sh mem_add mem_del quota_edit quota_get du.pl update_quota_mail.sh
|
||||
LIBS=functions.sh functions_hosting.sh functions_dns.sh
|
||||
BIN=$(DESTDIR)/usr/lib/alternc/
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#! /bin/bash
|
||||
|
||||
. /usr/lib/alternc/functions.sh
|
||||
|
||||
#Fist we set the quotas no 0 (infinite for each already existing account
|
||||
t=`mysql_query "UPDATE mailbox SET quota='0' WHERE quota IS NULL"`
|
||||
|
||||
|
||||
#Then we loop through every maildir to get the maildir size
|
||||
for i in $ALTERNC_LOC/mail/*/* ; do
|
||||
|
||||
user=`ls -l $i| tail -n 1|cut -d' ' -f 3`
|
||||
size=`du -s $i|awk '{print $1}'`
|
||||
q=`mysql_query "SELECT * FROM mailbox where path = '$i' "`
|
||||
|
||||
#when counting mails we eclude dovecot specific files
|
||||
mail_count=`find $i -type f |grep -v dovecot* |wc -l`
|
||||
echo "folder : "$i
|
||||
echo "mail count : "$mail_count
|
||||
echo "dir size : "$size
|
||||
echo ""
|
||||
|
||||
if [ -z "$q" ]; then
|
||||
echo "no mail folder found for user $user "
|
||||
else
|
||||
#update the mailbox table accordingly
|
||||
q=`mysql_query "UPDATE mailbox SET bytes=$size WHERE path='$i' "`
|
||||
q=`mysql_query "UPDATE mailbox SET messages=$mail_count WHERE path='$i' "`
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue