Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
a0653764
Commit
a0653764
authored
Nov 18, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive_spam.sh: improve to support users spambox too
parent
75f5f185
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
archive_spam.sh
mail/archive_spam.sh
+28
-14
No files found.
mail/archive_spam.sh
View file @
a0653764
...
...
@@ -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!"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment