#!/bin/sh
#
# overall run script.  Pretty much all of this file will change based on the rules
# being generated, and your local configuration.  

# where the scripts live.  This will need to be changed for each site
dir=/home/jm/ftp/spamassassin/masses/rule-dev/sought/example_backend

# change: where your svn checkout lives
sasvndir=/home/jm/ftp/spamassassin

# change: where to check in the output file to SVN
outsvndir=/home/jm/ftp/spamassassin

# change: the targets scanned
( command cd $sasvndir/masses && nice ./mass-check \
  --cf='loadplugin Dumptext plugins/Dumptext.pm' \
  --cf='loadplugin Mail::SpamAssassin::Plugin::Check' \
  -n -o -C=/dev/null \
  spam:mbox:$dir/cor-fraud/corpus_spam_fraud \
  spam:mbox:$dir/cor-guenther_fraud/spam/*fraud*.mbox \
  > $dir/all_w.s )

# change: the targets scanned
( command cd $sasvndir/masses && nice ./mass-check \
  --cf='loadplugin Dumptext plugins/Dumptext.pm' \
  --cf='loadplugin Mail::SpamAssassin::Plugin::Check' \
  -n -o -C=/dev/null \
  ham:detect:$dir/cor-ham/* \
  ham:mbox:$dir/cor-fraud/corpus_ham_fraud \
  ham:mbox:$dir/cor-guenther_fraud/ham/*fraud*.mbox \
  > $dir/w.h )

# add already-compiled old logs to the ham collection
cd $dir
cat logs.h/* w.h > all_w.h

# change: rule prefix, required pattern length, required hitrate thresholds
nice $sasvndir/masses/rule-dev/seek-phrases-in-log \
  --ham $dir/all_w.h \
  --spam $dir/all_w.s \
  --rules --ruleprefix __SEEK_FRAUD_ --reqpatlength 40 --reqhitrate "2.0 0.3 1.0" \
  > out.cf
$dir/kill_bad_patterns < out.cf > clean.cf
date

# change: rule prefix, target file location
$dir/mk_meta_rule JM_SOUGHT_FRAUD_ $dir/clean.cf > \
  $outsvndir/rulesrc/sandbox/jm/20_sought_fraud.cf \
  || exit 1

$sasvndir/spamassassin \
  -C $outsvndir/rulesrc/sandbox/jm/20_sought_fraud.cf --lint \
  || exit 1

svn commit -m "auto-generated test rules" \
  $outsvndir/rulesrc/sandbox/jm/20_sought_fraud.cf \
  || exit 1

# change: hostname, path to run on DNS host
ssh dnspublishinghost.example.com \
        /path/to/jm/svn/trunk/masses/rule-dev/sought/mkzone_remote_svn/run_part2

