1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#!/bin/sh
#
# check_mailscanner
#
# $Id: check_mailscanner 4164 2007-09-03 17:14:03Z sysjkf $
#
# 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.
# This can be called with a "-q" command-line option so that it is quiet
# unless MailScanner actually had to be started.
process=MailScanner
msbindir=/opt/MailScanner/bin
config=/opt/MailScanner/etc/MailScanner.conf
# These seem to get put all over the shop...
PATH=/usr/bin:/bin
export PATH
PERL=perl
AWK=awk
GREP=grep
FGREP=fgrep
EGREP=egrep
PGREP=pgrep
PS=ps
UNAME='uname -a'
#TAINTWARN='-Tw'
TAINTWARN=
RETVALUE=" Done."
# If this does not work on your system, please don't
# just send us a version that does, please please please
# send example output that demonstrates *why* it doesn't
# work, what version of what system you are running etc.
# If you do this then I *will* make this work right for
# everybody.
# -- Nick Phillips <nwp@lemon-computing.com>
if $UNAME | $FGREP "SunOS" >/dev/null ; then
# Version for Solaris/SysV systems:
pid=`$PGREP $process`
elif $UNAME | $FGREP "HP" >/dev/null ; then
# Version for HP-UX
pid=`ps -efx |
fgrep $msbindir/$process |
fgrep -v fgrep |
awk '{print $2}'`
elif $UNAME | $FGREP "SCO" >/dev/null ; then
pid=`ps -e -o pid -o args |
fgrep $msbindir/$process |
grep -v grep |
sed -e 's/^ *//' -e 's/ .*//'`
elif $UNAME | $FGREP "Linux" >/dev/null ; then
pid=`$PS axww |
$EGREP $process'[:]|\['$process'\]|[ ]'$msbindir/$process |
awk '{ print $1 }'`
elif $UNAME | $FGREP "BSD" >/dev/null ; then
pid=`$PS -axww |
$EGREP '[ ]('$msbindir/$process')|'$process'[:]' |
$AWK '{print $1}'`
elif $UNAME | $FGREP "OSF" >/dev/null ; then
pid=`ps -e -o pid -o args |
$GREP '[ ]'$process |
grep -v grep |
awk '{ print $1 }'`
elif $UNAME | $FGREP "Darwin" >/dev/null ; then # ie Mac OSX
pid=`$PS axww |
$EGREP '[ ]('$msbindir/$process')|'$process'[:]' |
$AWK '{print $1}'`
else
# not BSD; everything else seems to do POSIX
pid=`COLUMNS=500 $PS -ef |
$EGREP '([ ]'$msbindir/$process')|'$process'[:]' |
$AWK '{print $2}'`
fi
# Not needed after 4.61.6.
## Make it run SpamAssassin out of tmpfs
#if [ -d /dev/shm ]; then
# TMPDIR=/dev/shm
# export TMPDIR
#fi
if [ "x$pid" = "x" ]; then
# Quietly try to raise the open_files limit
ulimit -n 2000 >/dev/null 2>&1
# Restart it
PATH=${msbindir}:$PATH
echo -n 'Starting MailScanner...'
cd $msbindir
$process $config || RETVALUE=" Failed."
echo "$RETVALUE"
else
if [ "x$1" != "x-q" ]; then
echo MailScanner running with pid $pid
fi
fi
|