Commit a0653764 authored by Vitaly Lipatov's avatar Vitaly Lipatov

archive_spam.sh: improve to support users spambox too

parent 75f5f185
......@@ -15,13 +15,17 @@ archive_spamdir()
# skip empty spam dir
[ "$SIZE" = 4 ] && return
mkdir -p "$BACKUPDIR"
# TODO: use eterremove
# Нужно удалять только старый spam!
#etertimemachine update $SPAMDIR $BACKUPDIR
#etertimemachine rotate $BACKUPDIR
rm -rf $SPAMDIR.copy
cp -al $SPAMDIR $SPAMDIR.copy
find $SPAMDIR -maxdepth 1 -name "*\." -delete
cp -al $SPAMDIR $SPAMDIR.copy || exit
# Удаляем только старый спам (старее 3 месяцев)
#find $SPAMDIR -maxdepth 1 -name "*\." -delete
eterremove remove --depth 1 --exclude "cyrus.*" --days 30 --notest files $SPAMDIR
rm -f $SPAMDIR/cyrus.*
/usr/lib/cyrus/reconstruct "$SPAMBOX"
erc create "$BACKUPDIR/$(date -R).tar.gz" $SPAMDIR.copy
......@@ -47,27 +51,37 @@ archive_spam()
remove_from_domain()
{
local DOMAIN="$1"
local USER="$2"
local i
echo
echo $DOMAIN
for i in $IMAPDIR/$(fletter $DOMAIN)/$DOMAIN/?/user/* ; do
for i in $IMAPDIR/$(fletter $DOMAIN)/$DOMAIN/?/user/$USER ; do
USER=$(basename $i)
BOX=/spam
test -f "$i$BOX/cyrus.index" || continue
archive_spam $DOMAIN $USER $BOX
# recal quota for the user
[ "$USER" != "*" ] && /usr/lib/cyrus/quota -f -d $DOMAIN user/$USER
done
# recalc quotas
/usr/lib/cyrus/quota -f -d $DOMAIN || echo "You need fix this error!"
# recalc quotas for all users
if [ "$USER" = "*" ] ; then
/usr/lib/cyrus/quota -f -d $DOMAIN || echo "You need fix this error!"
fi
}
# Uncomment after improve old spam removing
#for d in $IMAPDIR/?/* ; do
# remove_from_domain $(basename $d)
#done
# test
#remove_from_domain office.etersoft.ru "arc"
#exit
for d in $IMAPDIR/?/* ; do
remove_from_domain $(basename $d) "*"
done
#exit
# main spam dir
DOMAIN=office.etersoft.ru
#user/spam@$DOMAIN
archive_spam $DOMAIN spam ""
# recalc quotas
/usr/lib/cyrus/quota -f -d $DOMAIN user/spam || echo "You need fix this error!"
USER=spam
archive_spam $DOMAIN $USER ""
# recalc quota for the spam user
/usr/lib/cyrus/quota -f -d $DOMAIN user/$USER || echo "You need fix this error!"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment