Import current code
This commit is contained in:
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Learn spam from Spam Maildir folder, ham from INBOX
|
||||
/usr/bin/sa-learn --spam --no-sync ~/Maildir/.Spam/cur
|
||||
/usr/bin/sa-learn --ham --no-sync ~/Maildir/cur
|
||||
/usr/bin/sa-learn --sync
|
||||
|
||||
# Removes all files from ~/Maildir/.Spam/cur that are older than
|
||||
# 31 days ago
|
||||
|
||||
find ~/Maildir/.Spam/cur -mtime +30 -exec rm -f {} \;
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
shopt -s extglob
|
||||
|
||||
while getopts u:d:p:f: option
|
||||
do
|
||||
case "${option}"
|
||||
in
|
||||
u) USER=${OPTARG};;
|
||||
d) DATE=${OPTARG};;
|
||||
p) PRODUCT=${OPTARG};;
|
||||
f) FORMAT=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
function examine
|
||||
{
|
||||
local subdir=$1
|
||||
if [[ -n "$subdir" ]]; then
|
||||
subdir="$subdir/"
|
||||
fi
|
||||
if [[ ! -d ./${subdir}cur ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local action=ham
|
||||
if [[ ! -z "$2" ]]; then
|
||||
action=$2
|
||||
fi
|
||||
|
||||
echo Learning from $subdir as $action
|
||||
pushd ${subdir}cur
|
||||
if [[ -f ~/.sa-learn/last$1 ]]; then
|
||||
find -H . -type f -regex ".*,[^,]*S[^,]*$" -newer ~/.sa-learn/last$1 -exec sa-learn --$action --no-sync {} \+;
|
||||
else
|
||||
find . -type f -regex ".,[^,]*S[^,]*$" -mtime -30 -exec sa-learn --$action --no-sync {} \+;
|
||||
fi
|
||||
rm -f ~/.sa-learn/last$1
|
||||
|
||||
if [[ $( ls *,*([!,])S*([!,]) 2>/dev/null ) ]]; then
|
||||
ln -s $( realpath $( ls -1t *,*([!,])S*([!,]) | head -1) ) ~/.sa-learn/last$1;
|
||||
fi
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
if [ -d ~/Maildir ]; then
|
||||
mkdir -p ~/.sa-learn
|
||||
pushd ~/Maildir
|
||||
|
||||
examine .Spam spam
|
||||
examine
|
||||
examine .Root
|
||||
for inboxdir in ./.INBOX*; do
|
||||
examine $(basename $inboxdir);
|
||||
done;
|
||||
|
||||
sa-learn --sync
|
||||
|
||||
popd
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
DescriptionExecutes sa-learn for each folder in each member of a given group Maildir folder
|
||||
Wants=sa-train.timer
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/sa-train.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=sa-train.target
|
||||
@@ -0,0 +1,3 @@
|
||||
[Unit]
|
||||
Description=Spamassassin learn Timer Target
|
||||
StopWhenUnneeded=yes
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Spamassassin Train Timer
|
||||
|
||||
[Timer]
|
||||
OnBootSec=5min
|
||||
OnCalendar=*-*-* 03:40:00
|
||||
Unit=sa-train.target
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
Reference in New Issue
Block a user