#!/bin/sh # # check_mailscanner # # $Id: check_mailscanner.tru64 1312 2002-12-26 23:55:35Z jkf $ # # Script to check whether mailscanner process is running, and # start it up if not. # # Copyright (C) 2002 Julian Field, Nick Phillips # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # The author, Julian Field, can be contacted by email at # Jules@JulianField.net # or by paper mail at # Julian Field # Dept of Electronics & Computer Science # University of Southampton # Southampton # SO17 1BJ # United Kingdom # # Check that the virus scanner is still running. # Re-start it if necessary. # This can also be used from the init script to # start it in the first place. process=mailscanner virusdir=/usr/local/MailScanner/bin config=/usr/local/MailScanner/etc/mailscanner.conf # These seem to get put all over the shop... PERL=/usr/bin/perl AWK=/usr/bin/awk GREP=/bin/grep # ...but surely everyone has these in /bin? PS=/bin/ps UNAME=/bin/uname if ( test -z "`$UNAME | $GREP BSD`" ) ; then # not BSD; everything else seems to do POSIX pid=`COLUMNS=500 $PS -ef | $GREP $virusdir'[ ]'$process | $AWK '{print $2}'` else # (Open|Free|Net)BSD pid=`$PS -axww | $GREP '[ ]'$virusdir/$process | $AWK '{print $1}'` fi if [ "$pid" = "" ]; then # Restart it PATH=${virusdir}:$PATH echo Starting MailScanner... cd $virusdir $PERL -I$virusdir $process $config else echo MailScanner running with pid $pid fi