delete imap-cache and rebuild

Discuss installation of Scalix software

Moderators: ScalixSupport, admin

mnauta
Posts: 152
Joined: Wed Feb 23, 2005 4:10 pm
Location: Austin, TX

delete imap-cache and rebuild

Postby mnauta » Tue Oct 20, 2009 4:22 pm

Hi,

I am doing an upgrade to 11.4.5 and need to clear imap cache for users and rebuild it to minimize login problems via SWA with people who have very large inboxes. I got this script from here and it works great for one user. How can the script be modified to run verbose, unattended for all scalix users?

Code: Select all

#!/bin/bash
if [ "$1" = "" ]
then
 echo "usage: $0 username"
 exit 1
fi
REALPATH=`/opt/scalix/bin/omrealpath "~/"`
OMSHOWU=`/opt/scalix/bin/omshowu -n "$1" -f 2>/dev/null| grep "User Folder"`
if [ $? -eq 0 ]
then
  FOLDER=`echo $OMSHOWU | awk -F/  '{print $2 "/" $3 }' `
  ID=`/opt/scalix/bin/omshowu -n "$1" | grep "System Login :" | awk -F: '{print $2}' `
 echo -n "Do you really want to remove the imap-cache for $1 (y/N)"
 read DOIT
 if [ "$DOIT" = "y" ]
 then
   echo "locking mail-account ..."
   /opt/scalix/bin/ommodu -o "$1" -K
   echo "killing IMAP-processes for user $1 (uid $ID) ..."
   pkill -u $ID in.imap41d
   echo "removing $REALPATH$FOLDER/imap-cache ..."
   rm -rf  $REALPATH$FOLDER/imap-cache
   echo -n "do you want to recreate the mailboxcache for $1 which can take a while (y/N)"
   read DOIT2
   if [ "$DOIT2" = "y" ]
   then
       echo "killing UAL-remote processes for user $1 (uid $ID) ..."
       pkill -u $ID ual.remote
       echo "removing $REALPATH$FOLDER/00000v8.ofs ..."
       rm -rf  $REALPATH$FOLDER/00000v8.ofs
       echo "recreating mailboxcache for $1...."
       /opt/scalix/bin/sxmbcprep -B -u "$1"
   fi
   omtidyu -B -M -u ' $1/sbgk'
   echo "unlocking mail-account ..."
   /opt/scalix/bin/ommodu -o "$1" -k
   echo "done!"
 fi
else
 echo "Can not find $1"
fi

billb3
Scalix Star
Scalix Star
Posts: 464
Joined: Mon May 26, 2008 8:56 pm
Location: Kingston, NY
Contact:

Re: delete imap-cache and rebuild

Postby billb3 » Tue Oct 20, 2009 4:24 pm

I run this ever few weeks just to be safe.
/usr/local/bin/clearimap.sh is a copy of the script you had in your post.

Code: Select all

#!/bin/bash

/opt/scalix/bin/omshowu -m all | egrep -v 'sxadmin|sxqueryadmin' | while read username
do
    echo "Processing User $username"
    /usr/local/bin/clearimap.sh -u "$username" -f
done
Last edited by billb3 on Tue Oct 20, 2009 4:31 pm, edited 1 time in total.

billb3
Scalix Star
Scalix Star
Posts: 464
Joined: Mon May 26, 2008 8:56 pm
Location: Kingston, NY
Contact:

Re: delete imap-cache and rebuild

Postby billb3 » Tue Oct 20, 2009 4:31 pm

I lied, here is the contents of the clearimap.sh script I referenced:

Code: Select all

#!/bin/bash
usage () {
echo "usage $0 [-fdkqh] -u username"
echo ""
echo " $0 is a script to handle IMAP and IMAP-cache related problems"
echo ""
echo "         -f: don't ask, just do"
echo "         -d: save the old imap-cache folder and dump IMAP related entries from the eventlog to /tmp"
echo "         -k: just kill the IMAP sessions, dont remove the cache-folder"
echo "         -q: quiet mode"
echo "         -h: help (this text)"
echo "         -u: username as used by omshowu -u"
exit 1
}
while getopts ':fdkhqu:' OPTION ; do
  case $OPTION in
    f )   FORCE=true;;
    d )   DEBUG=true;;
    k )   KILLONLY=true;;
    h )   usage;;
    q )   QUIET=true;;
    u )   NAME=$OPTARG;;
    \? )  echo "unknown option \"-$OPTARG\"."
          usage ;;
    : )   echo "option \"-$OPTARG\" needs an argument"
          usage ;;
    * )   usage;;
  esac
done
if [ "x" == "x$NAME" ]; then
  echo "-u username is required"
  usage
  exit
fi

REALPATH='/var/opt/scalix/el/s/'
OMSHOWU=`/opt/scalix/bin/omshowu -n "$NAME" -f 2>/dev/null| grep "User Folder"`
if [ $? -eq 0 ]
then
   FOLDER=`echo $OMSHOWU | awk -F/  '{print $2 "/" $3 }' `
   ID=`/opt/scalix/bin/omshowu -n "$NAME" | grep "System Login :" | awk -F: '{print $2}' `
   if [ "$FORCE" ]; then
        DOIT=y
   else
        echo -n "Do you really want to remove the imap-cache for $NAME (y/N)"
        read DOIT
   fi
   if [ "$DOIT" = "y" ]; then
     if [ ! "$QUIET" ]; then echo "locking mail-account ..."; fi
     /opt/scalix/bin/ommodu -o "$NAME" -K 2>/dev/null
     if [ ! "$QUIET" ]; then echo "killing IMAP-processes for user $NAME (uid $ID) ..."; fi
     pkill -u $ID in.imap41d
     if [ ! "$KILLONLY" ]; then
       if [ ! -d $REALPATH$FOLDER/imap-cache ]; then
         echo "sorry, no imap-cache for mailbox $NAME"
       else
         if [ "$DEBUG" ]; then
           if [ -f /tmp/imap-cache.tgz ]; then rm -f /tmp/imap-cache.tgz; fi
           if [ ! "$QUIET" ]; then echo "storing imap-cache in /tmp/imap-cache.tgz"; fi
           tar cfz /tmp/imap-cache.tgz $REALPATH$FOLDER/imap-cache 2>/dev/null
           if [ ! "$QUIET" ]; then echo "saving IMAP entries in omshowlog for last 24 hours in /tmp/omshowlog-imap.txt"; fi
           /opt/scalix/bin/omshowlog -p 1440 -s imap > /tmp/omshowlog-imap.txt
         fi
         if [ ! "$QUIET" ]; then echo "removing $REALPATH$FOLDER/imap-cache ..."; fi
         rm -rf  $REALPATH$FOLDER/imap-cache
       fi
     fi
     if [ ! "$QUIET" ]; then echo "unlocking mail-account ..."; fi
     /opt/scalix/bin/ommodu -o "$NAME" -k 2> /dev/null
     if [ ! "$QUIET" ]; then echo "done!"; fi
   fi
else
  echo "can not find a mailbox $NAME"
fi

les
Scalix Star
Scalix Star
Posts: 819
Joined: Thu Feb 23, 2006 10:18 am
Location: Sydney, Australia

Re: delete imap-cache and rebuild

Postby les » Wed Oct 21, 2009 8:23 am

billb3 wrote:REALPATH='/var/opt/scalix/el/s/'


That's a nice script. One helpful change to the above so the clearimap.sh script never has to be edited and can run from any system.....

REALPATH=`/opt/scalix/bin/omcheckgc -d`
Regards,

Les Stott


Return to “Installation”



Who is online

Users browsing this forum: No registered users and 5 guests

cron