Spam and ham filtering for multiple users
This commit is contained in:
parent
b1783bf396
commit
bc8a29b94b
|
@ -6333,44 +6333,54 @@ function spam_filtering {
|
||||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.procmailrc
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.procmailrc
|
||||||
# filtering scripts
|
# filtering scripts
|
||||||
echo '#!/bin/bash' > /usr/bin/filterspam
|
echo '#!/bin/bash' > /usr/bin/filterspam
|
||||||
echo 'USERNAME=$1' >> /usr/bin/filterspam
|
echo 'for d in /home/*/ ; do' >> /usr/bin/filterspam
|
||||||
echo 'MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
|
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/filterspam
|
||||||
echo 'if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
|
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/filterspam
|
||||||
echo ' exit' >> /usr/bin/filterspam
|
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
|
||||||
echo 'fi' >> /usr/bin/filterspam
|
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
|
||||||
echo 'for f in `ls $MAILDIR/cur`' >> /usr/bin/filterspam
|
echo ' exit' >> /usr/bin/filterspam
|
||||||
echo 'do' >> /usr/bin/filterspam
|
echo ' fi' >> /usr/bin/filterspam
|
||||||
echo ' spamc -L spam < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterspam
|
echo ' for f in `ls $MAILDIR/cur`' >> /usr/bin/filterspam
|
||||||
echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterspam
|
echo ' do' >> /usr/bin/filterspam
|
||||||
echo 'done' >> /usr/bin/filterspam
|
echo ' spamc -L spam < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterspam
|
||||||
echo 'for f in `ls $MAILDIR/new`' >> /usr/bin/filterspam
|
echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterspam
|
||||||
echo 'do' >> /usr/bin/filterspam
|
echo ' done' >> /usr/bin/filterspam
|
||||||
echo ' spamc -L spam < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterspam
|
echo ' for f in `ls $MAILDIR/new`' >> /usr/bin/filterspam
|
||||||
echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterspam
|
echo ' do' >> /usr/bin/filterspam
|
||||||
|
echo ' spamc -L spam < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterspam
|
||||||
|
echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterspam
|
||||||
|
echo ' done' >> /usr/bin/filterspam
|
||||||
|
echo ' fi' >> /usr/bin/filterspam
|
||||||
echo 'done' >> /usr/bin/filterspam
|
echo 'done' >> /usr/bin/filterspam
|
||||||
|
echo 'exit 0' >> /usr/bin/filterspam
|
||||||
|
|
||||||
echo '#!/bin/bash' > /usr/bin/filterham
|
echo '#!/bin/bash' > /usr/bin/filterham
|
||||||
echo 'USERNAME=$1' >> /usr/bin/filterham
|
echo 'for d in /home/*/ ; do' >> /usr/bin/filterham
|
||||||
echo 'MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
|
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/filterham
|
||||||
echo 'if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
|
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/filterham
|
||||||
echo ' exit' >> /usr/bin/filterham
|
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
|
||||||
echo 'fi' >> /usr/bin/filterham
|
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
|
||||||
echo 'for f in `ls $MAILDIR/cur`' >> /usr/bin/filterham
|
echo ' exit' >> /usr/bin/filterham
|
||||||
echo 'do' >> /usr/bin/filterham
|
echo ' fi' >> /usr/bin/filterham
|
||||||
echo ' spamc -L ham < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterham
|
echo ' for f in `ls $MAILDIR/cur`' >> /usr/bin/filterham
|
||||||
echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterham
|
echo ' do' >> /usr/bin/filterham
|
||||||
echo 'done' >> /usr/bin/filterham
|
echo ' spamc -L ham < "$MAILDIR/cur/$f" > /dev/null' >> /usr/bin/filterham
|
||||||
echo 'for f in `ls $MAILDIR/new`' >> /usr/bin/filterham
|
echo ' rm "$MAILDIR/cur/$f"' >> /usr/bin/filterham
|
||||||
echo 'do' >> /usr/bin/filterham
|
echo ' done' >> /usr/bin/filterham
|
||||||
echo ' spamc -L ham < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterham
|
echo ' for f in `ls $MAILDIR/new`' >> /usr/bin/filterham
|
||||||
echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterham
|
echo ' do' >> /usr/bin/filterham
|
||||||
|
echo ' spamc -L ham < "$MAILDIR/new/$f" > /dev/null' >> /usr/bin/filterham
|
||||||
|
echo ' rm "$MAILDIR/new/$f"' >> /usr/bin/filterham
|
||||||
|
echo ' done' >> /usr/bin/filterham
|
||||||
|
echo ' fi' >> /usr/bin/filterham
|
||||||
echo 'done' >> /usr/bin/filterham
|
echo 'done' >> /usr/bin/filterham
|
||||||
|
echo 'exit 0' >> /usr/bin/filterham
|
||||||
|
|
||||||
if ! grep -q "filterspam" /etc/crontab; then
|
if ! grep -q "filterspam" /etc/crontab; then
|
||||||
echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterspam $MY_USERNAME" >> /etc/crontab
|
echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterspam" >> /etc/crontab
|
||||||
fi
|
fi
|
||||||
if ! grep -q "filterham" /etc/crontab; then
|
if ! grep -q "filterham" /etc/crontab; then
|
||||||
echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterham $MY_USERNAME" >> /etc/crontab
|
echo "*/3 * * * * root /usr/bin/timeout 120 /usr/bin/filterham" >> /etc/crontab
|
||||||
fi
|
fi
|
||||||
chmod 655 /usr/bin/filterspam /usr/bin/filterham
|
chmod 655 /usr/bin/filterspam /usr/bin/filterham
|
||||||
sed -i 's/# use_bayes 1/use_bayes 1/g' /etc/mail/spamassassin/local.cf
|
sed -i 's/# use_bayes 1/use_bayes 1/g' /etc/mail/spamassassin/local.cf
|
||||||
|
|
Loading…
Reference in New Issue