#! /bin/sh
# File:       mf-reset
# Version:    1.14
# Purpose:    Tells mail filter to read its configuration files
# Written by: R. Butler <butlerra@sbu.ac.uk>
# Date:       29-Jun-2000
# Revised:    08-Mar-2001
#
# Copyright (C) 2001 South Bank University, London
# (Please see the full copyright notice in 'copyright.txt')

FILTER=$1
BN_FILTER=`basename $FILTER`

# Check that the WORK_DIR variable has been exported
if [ -z "$WORK_DIR" ]
then
   echo " "
   echo "$0: Variable WORK_DIR is not defined"
   echo "To reset the mail filter, please use the command:"
   echo "   mail-filter reset"
   echo " "
   exit 3
fi
LOGFILE="$WORK_DIR/mail-filter.log"

FILTER_PID=`ps -ef | grep $FILTER | grep -v $0 \
           | grep -v 'mf-start' | grep -v 'grep' \
           | awk '{print $2}'`
if [ -n "$FILTER_PID" ]
then
   kill -USR1 $FILTER_PID
   echo " "
   echo "$0: Signalled $BN_FILTER to read configuration files"
   if [ -n "$WORK_DIR" ]
   then
      DATE=`date +"%d-%b-%Y %T"`
      echo "$DATE : Signalling $BN_FILTER to read configuration files" \
         >> $LOGFILE
   fi
else
   echo " "
   echo "$0: Could not determine PID for $BN_FILTER"
   echo "$BN_FILTER may not be running." 
fi

