Gentoo Archives: gentoo-server

From: Lance Lassetter <lance@×××××××.info>
To: gentoo-server@××××××××××××.org
Subject: Re: [gentoo-server] simple shell script
Date: Sun, 03 Apr 2005 03:05:43
Message-Id: 1112497646.32535.2.camel@localhost.localdomain
In Reply to: Re: [gentoo-server] simple shell script by Lance Lassetter
1 Corrected.
2
3 The only difference is spam.pid moved to /tmp/ so that imap folder don't
4 get confused, if possible. This will work if more than one user and
5 using global SQL SA bayesian filtering (I think). :)
6
7 #!/bin/bash
8
9 for user in /home/*/;
10 do cd "$user";
11 if [ -d "mail" ]; then
12 cd mail;
13 if [ -f "Junk E-mail" ]; then
14 cp "Junk E-mail" /tmp/spam.$$
15 /usr/bin/sa-learn -u amavis -C /etc/mail/spamassassin --spam
16 --mbox /tmp/spam.$$
17 rm /tmp/spam.$$
18 fi
19 fi
20 done
21
22 lance(stuNNed)
23
24 On Sat, 2005-04-02 at 20:47 -0600, Lance Lassetter wrote:
25 > Here's mine for mbox format:
26 >
27 > #!/bin/bash
28 >
29 > for user in /home/*/;
30 > do cd "$user";
31 > if [ -d "mail" ]; then
32 > cd mail;
33 > if [ -f "Junk E-mail" ]; then
34 > cp "Junk E-mail" spam.$$
35 > /usr/bin/sa-learn -u amavis -C /etc/mail/spamassassin --spam --mbox
36 > spam.$$
37 > rm spam.$$
38 > fi
39 > fi
40 > done
41 >
42 > On Sun, 2005-04-03 at 03:41 +0200, Scott Storck wrote:
43 > > Ben Munat schrieb:
44 > >
45 > > > Yeah, running sa-learn on an empty directory is fine, but it bugs me
46 > > > that when I then run rm on the contents of that directory, I get an
47 > > > error message. I know it doesn't hurt anything... it just bugs me. I
48 > > > thought it would be trivial to put the calls to "sa-learn" and "rm" in
49 > > > an if statement, but I guess I was wrong.
50 > > >
51 > > No, you are right, it is not hard you just need to know how to do it.
52 > > Here is part of my login script.
53 > > It does exactly what you want.
54 > >
55 > > ------snip--------------
56 > > #change spamdir to the directoy you want to process
57 > > spamdir=/home/l0ner/.maildir/.spam
58 > > if ls -1 $spamdir 1>/dev/null 2>&1
59 > > then
60 > > for spamdirfile in `ls -1 $spamdir`
61 > > do
62 > > spamfile=$spamdir/$spamdirfile
63 > > if test -f $spamfile
64 > > then
65 > > sa-learn --spam $spamfile
66 > > rm $spamfile
67 > > fi
68 > > done
69 > > fi
70 > > ------snip--------------
71 > >
72 > > BTW, Don't forget to run it over ham too. SA needs to learn both ham and
73 > > spam for the bayes to function. :^)
74 > >
75 > > > b
76 > >
77 > > -l0ner
78 > >
79 > > --
80 > > gentoo-server@g.o mailing list
81 >
82 > --
83 > gentoo-server@g.o mailing list
84
85 --
86 gentoo-server@g.o mailing list