Diferencia entre revisiones de «Cyrus Imap»

De gacq wiki
Saltar a: navegación, buscar
(Quota monitoring and warning mail)
 
(No se muestra una edición intermedia del mismo usuario)
Línea 52: Línea 52:
 
chown -R cyrus:mail /var/spool/cyrus
 
chown -R cyrus:mail /var/spool/cyrus
 
chown -R cyrus:mail /var/lib/cyrus
 
chown -R cyrus:mail /var/lib/cyrus
 +
</pre>
 +
 +
== Quota monitoring and warning mail ==
 +
<pre>
 +
#!/bin/bash
 +
#
 +
 +
USERWARN=70
 +
 +
function send_warnmail {
 +
noti_mailbox=$1
 +
noti_used=$2
 +
/kolab/sbin/sendmail $noti_mailbox << EOM
 +
subject: ATENCION: La casilla $noti_mailbox esta al % $noti_used de su capacidad
 +
from: Mail server <postmaster@domain.com>
 +
to: $noti_mailbox
 +
 +
ATENCION: La casilla $noti_mailbox esta al % $noti_used de su capacidad
 +
 +
EOM
 +
}
 +
 +
/kolab/bin/cyrquota | while read line
 +
do
 +
  used=`echo $line | cut -d" " -f2`
 +
  mailbox=`echo $line | cut -d" " -f4 | cut -d"/" -f2`
 +
 +
  if [ "$used" != "%" ]
 +
  then
 +
      if [ $used -gt $USERWARN ] && [ $used -lt 100 ]
 +
      then
 +
          send_warnmail $mailbox $used
 +
      fi
 +
  fi
 +
done
 +
</pre>
 +
 +
== Quota monitoring - Admin report ==
 +
<pre>
 +
#!/bin/bash
 +
#
 +
 +
MAX=70
 +
ADMIN=admin@domain.com
 +
 +
function enviar_reporte {
 +
/kolab/sbin/sendmail $ADMIN << EOM
 +
subject: KOLAB - Informe de uso de casillas de correo
 +
from: Mail server <postmaster@domain.com>
 +
to: $ADMIN
 +
 +
    Casilla    -    Porcentaje usado
 +
#####################################
 +
`listar_llenas|sort -n -k3 -r`
 +
 +
EOM
 +
}
 +
 +
function listar_llenas {
 +
/kolab/bin/cyrquota | while read line
 +
do
 +
  used=`echo $line | cut -d" " -f2`
 +
  mailbox=`echo $line | cut -d" " -f4 | cut -d"/" -f2`
 +
 +
  if [ "$used" != "%" ]
 +
  then
 +
      if [ $used -gt $MAX ]
 +
      then
 +
          echo $mailbox - $used
 +
      fi
 +
  fi
 +
done
 +
}
 +
 +
enviar_reporte
 
</pre>
 
</pre>

Revisión actual del 18:05 27 sep 2010

Subpages

Utils

Search and expunge a set of folders

import imaplib

imap = imaplib.IMAP4()
imap.login('manager', 'thepasswd')

for mbox in imap.list('', '*quotatest1*')[1]:
    mailbox=mbox.split('"')[3]
    imap.setacl(mailbox,'manager', 'lrswikxtecda')
    print imap.select(mailbox)
    print imap.expunge()
    imap.setacl(mailbox,'manager', '')

Migrate mbolixt script

import fileinput

for line in fileinput.input( "source-ctl_mboxlist-d" ):

  mailbox_end = line.find(".",5)
  if ( mailbox_end == -1 ):
    mailbox_end = line.find("\t",5)
    folder = ""
  else:
    folder = line[mailbox_end+1:line.find("\t",mailbox_end)]

  mailbox=line[5:mailbox_end]

  if folder:
    print "mailserver.gacq.com!user.%s.%s\t0 default %s@mailserver.gacq.com\tlrswipkxtecda\t" % (mailbox,folder,mailbox)
  else:
    print "mailserver.gacq.com!user.%s\t0 default %s@mailserver.gacq.com\tlrswipkxtecda\t" % (mailbox,mailbox)

Recreate cyrus spool and database folders

#rm -fr /var/spool/cyrus
#rm -fr /var/lib/cyrus
mkdir /var/spool/cyrus
mkdir /var/lib/cyrus
./cyrus-makedirs --cleansquat
chown -R cyrus:mail /var/spool/cyrus
chown -R cyrus:mail /var/lib/cyrus

Quota monitoring and warning mail

#!/bin/bash
#

USERWARN=70

function send_warnmail {
noti_mailbox=$1
noti_used=$2
/kolab/sbin/sendmail $noti_mailbox << EOM
subject: ATENCION: La casilla $noti_mailbox esta al % $noti_used de su capacidad
from: Mail server <postmaster@domain.com>
to: $noti_mailbox

ATENCION: La casilla $noti_mailbox esta al % $noti_used de su capacidad

EOM
}

/kolab/bin/cyrquota | while read line
do
   used=`echo $line | cut -d" " -f2`
   mailbox=`echo $line | cut -d" " -f4 | cut -d"/" -f2`

   if [ "$used" != "%" ]
   then
      if [ $used -gt $USERWARN ] && [ $used -lt 100 ]
      then
          send_warnmail $mailbox $used
      fi
   fi
done

Quota monitoring - Admin report

#!/bin/bash
#

MAX=70
ADMIN=admin@domain.com

function enviar_reporte {
/kolab/sbin/sendmail $ADMIN << EOM
subject: KOLAB - Informe de uso de casillas de correo
from: Mail server <postmaster@domain.com>
to: $ADMIN

     Casilla    -    Porcentaje usado
#####################################
`listar_llenas|sort -n -k3 -r`

EOM
}

function listar_llenas {
/kolab/bin/cyrquota | while read line
do
   used=`echo $line | cut -d" " -f2`
   mailbox=`echo $line | cut -d" " -f4 | cut -d"/" -f2`

   if [ "$used" != "%" ]
   then
      if [ $used -gt $MAX ]
      then
          echo $mailbox - $used
      fi
   fi
done
}

enviar_reporte