diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-11-10 14:41:38 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-11-10 14:43:14 -0500 |
commit | 09366721b4a5405ccd24e21c9f0c4edd25d51196 (patch) | |
tree | fd72dec2d55f51aecc1b76b01dd7ed18c1be9d87 /bin/tozt | |
parent | 12d2a797346af8fc2908bf5d7873414811a7e9cc (diff) | |
download | conf-09366721b4a5405ccd24e21c9f0c4edd25d51196.tar.gz conf-09366721b4a5405ccd24e21c9f0c4edd25d51196.zip |
various script cleanups
Diffstat (limited to 'bin/tozt')
-rwxr-xr-x | bin/tozt/learn_spam | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/tozt/learn_spam b/bin/tozt/learn_spam index ab5603a..128ca9a 100755 --- a/bin/tozt/learn_spam +++ b/bin/tozt/learn_spam @@ -1,10 +1,12 @@ -#!/bin/bash +#!/bin/sh +set -eu +set -o pipefail MAILDIR=~/Maildir OPTS="--no-sync" SALEARN=/usr/bin/vendor_perl/sa-learn -if [[ "$1" == "-q" ]]; then +if [ "$1" = "-q" ]; then OPTS="$OPTS" OUTFILE="/dev/null" else @@ -12,25 +14,25 @@ else OUTFILE="/dev/stdout" fi -if [[ ! "$1" == "-q" ]]; then +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 + xargs -n1000 -0 $SALEARN "$OPTS" --ham > $OUTFILE -if [[ ! "$1" == "-q" ]]; then +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 + xargs -n1000 -0 $SALEARN "$OPTS" --spam > $OUTFILE -if [[ ! "$1" == "-q" ]]; then +if [ ! "$1" = "-q" ]; then echo "$(date): Syncing..." fi nice $SALEARN --sync > $OUTFILE -if [[ ! "$1" == "-q" ]]; then +if [ ! "$1" = "-q" ]; then echo "$(date): Done!" fi |