v5/common/usr/sbin/ms-update-vs
Jerry.Benton 504f8bb291 update
none
2016-04-29 04:36:02 -04:00

77 lines
2.2 KiB
Bash

#!/bin/sh
# update virus scanners
# updated: Jerry Benton <mailscanner@mailborder.com>
# 28 APR 2016
ms_conf=/etc/MailScanner/MailScanner.conf
ms_vs_conf=/etc/MailScanner/virus.scanners.conf
# basic config file
if [ -f /etc/MailScanner/defaults ] ; then
. /etc/MailScanner/defaults
else
logger -i -p mail.notice "ERROR: ms-update-vs missing configuration file /etc/MailScanner/defaults"
echo "Aborted: missing configuration file /etc/MailScanner/defaults"
exit 1
fi
LOCKDIR=`/usr/sbin/ms-peek lockfiledir ${ms_conf}`
RUNASU=`/usr/sbin/ms-peek runasuser ${ms_conf}`
RUNASG=`/usr/sbin/ms-peek runasgroup ${ms_conf}`
Disabled=no
if [ "x$Disabled" = "xyes" ]; then
exit 0
fi
LOCKFILE=/tmp/MailScanner.autoupdate.lock
[ x`perl -e 'print "link" if -l "'$LOCKFILE'"'` = "xlink" ] && rm -f $LOCKFILE
# the lockfile is not meant to be perfect, it's just in case the
# two cron scripts get run close to each other to keep them from
# stepping on each other's toes.
[ x`perl -e 'print "young" if -f "'$LOCKFILE'" && -M "'$LOCKFILE'"<0.042'` = "xyoung" ] && exit 0
#[ -f $LOCKFILE ] && [ "`find $LOCKFILE -type f -mmin +60 -print`" = "" ] && exit 0
trap "rm -f $LOCKFILE" EXIT
touch $LOCKFILE
# Set umask so user mail can read (and share-lock) the Busy.lock files
umask 022
# Solaris requires xpg4 not normal grep for "-e" option
OS=`uname`
if [ "$OS" = "SunOS" ]; then
GREP=/usr/xpg4/bin/grep
else
GREP=grep
fi
[ -x /usr/sbin/ms-create-locks ] && \
/usr/sbin/ms-create-locks "$LOCKDIR" "$RUNASU" "$RUNASG"
cat ${ms_vs_conf} | sed -e 's/#.*$//' | ${GREP} -e -wrapper | \
while read NAME WRAPPER PACKAGEDIR
do
#echo String is $NAME $WRAPPER $PACKAGEDIR
UPDATER=`echo $WRAPPER | sed -e 's/wrapper$/autoupdate/g'`
LOCK=`echo $WRAPPER | sed -e 's/^.*\///g' -e 's/-wrapper$//'`
LOCK="${LOCKDIR}/${LOCK}Busy.lock"
if [ -n "${NAME}" -a -n "${WRAPPER}" -a -n "${PACKAGEDIR}" ]
then
if ${WRAPPER} ${PACKAGEDIR} -IsItInstalled
then
#echo Found $NAME installed
logger -p mail.notice -t ms-update-vs Found $NAME installed
if [ -x ${UPDATER} ]
then
#echo Updating $NAME
logger -p mail.info -t ms-update-vs Running autoupdate for $NAME
${UPDATER} "${PACKAGEDIR}" "${LOCK}" >/dev/null 2>&1
fi
fi
fi
done
exit 0