summaryrefslogtreecommitdiffstats
path: root/bin/tozt
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-10-29 03:13:31 -0400
committerJesse Luehrs <doy@tozt.net>2018-10-29 03:13:31 -0400
commit243e280b5fd9527891a58d6578f2e659302908c7 (patch)
tree1443d96e6824c8e04355c2f1fb2c562a9afe2132 /bin/tozt
parentdb8dd3e6140e66db46f309bff9054ba137eb797a (diff)
downloadconf-243e280b5fd9527891a58d6578f2e659302908c7.tar.gz
conf-243e280b5fd9527891a58d6578f2e659302908c7.zip
just use hostnames for this stuff
i don't really want another level of indirection
Diffstat (limited to 'bin/tozt')
-rwxr-xr-xbin/tozt/learn_spam36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/tozt/learn_spam b/bin/tozt/learn_spam
new file mode 100755
index 0000000..ab5603a
--- /dev/null
+++ b/bin/tozt/learn_spam
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+MAILDIR=~/Maildir
+OPTS="--no-sync"
+SALEARN=/usr/bin/vendor_perl/sa-learn
+
+if [[ "$1" == "-q" ]]; then
+ OPTS="$OPTS"
+ OUTFILE="/dev/null"
+else
+ OPTS="$OPTS --showdots"
+ OUTFILE="/dev/stdout"
+fi
+
+if [[ ! "$1" == "-q" ]]; then
+ echo "$(date): Learning ham..."
+fi
+nice find $MAILDIR -type f | \
+ perl -nl0e'chomp; ($ts) = /(\d{10})/; $now = time; print if m{/(new|cur)/} && !m{/(\.old|\.spam)/} && $ts > $now - 60*60*24*30' | \
+ xargs -n1000 -0 $SALEARN $OPTS --ham > $OUTFILE
+
+if [[ ! "$1" == "-q" ]]; then
+ echo "$(date): Learning spam..."
+fi
+nice find $MAILDIR -type f | \
+ perl -nl0e'chomp; ($ts) = /(\d{10})/; $now = time; print if m{/(new|cur)/} && m{/\.spam/} && $ts > $now - 60*60*24*30' | \
+ xargs -n1000 -0 $SALEARN $OPTS --spam > $OUTFILE
+
+if [[ ! "$1" == "-q" ]]; then
+ echo "$(date): Syncing..."
+fi
+nice $SALEARN --sync > $OUTFILE
+
+if [[ ! "$1" == "-q" ]]; then
+ echo "$(date): Done!"
+fi