initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.

This commit is contained in:
Dave Lane 2016-03-16 13:43:31 +13:00
commit 43e0f5b59e
329 changed files with 31937 additions and 0 deletions

79
egspamtraining/egspamtraining Executable file
View file

@ -0,0 +1,79 @@
#!/bin/bash
#
# egspamtraining
#
# (c) 2009 Egressive Limited
# Spam and ham training for spam assassin
# by ross@egressive.com
# Command definitions
CAT_COMMAND=`which cat`
MKDIR_COMMAND=`which mkdir`
CP_COMMAND=`which cp`
SUDO_COMMAND=`which sudo`
CHOWN_COMMAND=`which chown`
MAIL_COMMAND=`which mail`
RM_COMMAND=`which rm`
HEAD_COMMAND=`which head`
TAIL_COMMAND=`which tail`
DIRNAME_COMMAND=`which dirname`
BASENAME_COMMAND=`which basename`
SA_LEARN_COMMAND=`which sa-learn`
#defining conf file
EGST_DIR=`$DIRNAME_COMMAND $0`
EGST_SCRIPT=`$BASENAME_COMMAND $0`
CONF_FILE=$EGST_DIR/$EGST_SCRIPT.conf
TRAIN_TYPE=$1 #ham or spam training
CONF2_FILE=$EGST_DIR/$1.conf
MAIL_TO=root # placeholder, defined in egspamtraining.conf
# checking for egspamtraining.conf
if [ -f $CONF_FILE ] ; then
. $CONF_FILE
else
echo "Cannot find conf file" | $MAIL_COMMAND -s "[ERROR] Could not locate conf file for Spam/Ham training" $MAIL_TO
exit 1
fi
# Checking that spam/ham was specified when executing script
if [ "$TRAIN_TYPE" == "spam" ] ; then
echo "Spam Training" >> $LOGFILE
elif [ "$TRAIN_TYPE" == "ham" ] ; then
echo "Ham Training" >> $LOGFILE
else
echo "Training type not specified" | $MAIL_COMMAND -s "[ERROR] Training not specified" $MAIL_TO
exit 1
fi
if ! [ -f $CONF2_FILE ] ; then
echo "Cannot find $CONF2_FILE" | $MAIL_COMMAND -s "[ERROR] Could not locate $CONF2_FILE for $TRAIN_TYPE training" $MAIL_TO
exit 1
fi
# Here the training begins
echo `date` >> $LOGFILE
$MKDIR_COMMAND $TMPDIR # temp directory to copy emails to
# getting list of directories to copy emails from from ham/spam.conf and copying emails to temp directory.
LINES=2
NO_LINES=`wc -l $CONF2_FILE`
LINE_TOTAL=`expr "$NO_LINES" : '\([0-9]*\)'`
while [ "$LINES" -lt "$LINE_TOTAL" ]
do
let LINES=LINES+1
$CP_COMMAND `head -n $LINES $CONF2_FILE | tail -n 1` $TMPDIR
done
$CHOWN_COMMAND -R postfix:postfix $TMPDIR #need to change ownership of files for postfix to read
# Running the training as postfix to preserve bayes db permissions
$SUDO_COMMAND -H -u postfix $SA_LEARN_COMMAND -C $MAILSCANNER_CONF --$TRAIN_TYPE $TMPDIR/ >> $LOGFILE 2>> $LOGFILE
$RM_COMMAND -r $TMPDIR # removing temp directory
exit 0

View file

@ -0,0 +1,8 @@
#
# egspamtraining, copyright 2009 egressive limited, www.egressive.com
#
#
# daily - at 6:30 pm, mon-sun
30 6 * * * root /etc/egscripts/egspamtraining/egspamtraining spam
45 6 * * * root /etc/egscripts/egspamtraining/egspamtraining ham

View file

@ -0,0 +1,15 @@
# Configuration Variables for egspamtraining
#
# Name of Server
SERVERNAME="mail.tourism.net.nz"
#
# Logfile name
EGST_LOGNAME="egspamtraining"
LOGFILE="/var/log/$EGST_LOGNAME.log"
TMPDIR="/tmp/mail"
MAILSCANNER_CONF="/etc/MailScanner/spam.assassin.prefs.conf"
#
MAIL_TO="ross@egressive.com"
#

11
egspamtraining/ham.conf Normal file
View file

@ -0,0 +1,11 @@
#Conf file for mail directories to use for Spam training.
### List full directories below this line without quotes, eg /home/user/mail/inbox.directory/cur/*
/home/nzto4/.Mail/.INBOX.Lana/cur/*
/home/nzto4/.Mail/.INBOX.Passwords/cur/*
/home/nzto4/.Mail/.Comptitions/cur/*
/home/nzto4/.Mail/.Sales/cur/*
/home/nzto12/.Mail/.INBOX.Bookit/cur/*
/home/nzto12/.Mail/.INBOX.Competitions/cur/*
/home/nzto12/.Mail/.INBOX.Orders/cur/*
/home/nzto12/.Mail/.INBOX.Montastic/cur/*

View file

@ -0,0 +1,7 @@
/var/log/egspamtraining.log {
daily
missingok
rotate 7
compress
notifempty
}

4
egspamtraining/spam.conf Normal file
View file

@ -0,0 +1,4 @@
#Conf file for mail directories to use for Spam training.
#List full directories below this line in quotes.
/home/nzto4/.Mail/.Junk/cur/*
/home/nzto12/.Mail/.Junk/cur/*