summaryrefslogtreecommitdiff
path: root/security/uvscan/files
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2002-08-07 05:42:12 +0000
committerjlam <jlam@pkgsrc.org>2002-08-07 05:42:12 +0000
commitb23b831acc5f3fa3af35dbe13d151170186b78b3 (patch)
tree9ee40362de39f23fe0c1595bb669367f854f64a0 /security/uvscan/files
parent3700725038f93920c71da10699456dc7a08d2895 (diff)
downloadpkgsrc-b23b831acc5f3fa3af35dbe13d151170186b78b3.tar.gz
Merge security/uvscan-dat into security/uvscan. The uvscan-dat package is
out-of-date very frequently, and it's sole purpose seems to be to provide the uvscan package with the update_dat script so that uvscan can keep up-to-date with the latest virus definitions. A MESSAGE file has been added to security/uvscan that recommends running "update_dat" to update the virus definitions database to the most recent version after installation. The update_dat script has also been rewritten to allow the new syntax "update -f <DATFILE>" to update from an already- downloaded DATFILE, so users will still be able to do bulk downloads to removable media on a machine with a fat connection and be able to compile and install a usable uvscan package on another machine. Bump the PKGREVISION on uvscan to 1 and mark the CONFLICT with the obsolete uvscan-dat packages.
Diffstat (limited to 'security/uvscan/files')
-rw-r--r--security/uvscan/files/update_dat.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/security/uvscan/files/update_dat.sh b/security/uvscan/files/update_dat.sh
new file mode 100644
index 00000000000..540404d59de
--- /dev/null
+++ b/security/uvscan/files/update_dat.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+UVSCANDIR="@UVSCANDIR@"
+DAT_SITE="ftp://ftp.nai.com/pub/datfiles/english/"
+DAT_FILES="@DATFILES@"
+TMPDIR="${TMPDIR:-/tmp}/$$"
+
+AWK="@AWK@"
+BASENAME="@BASENAME@"
+CP="@CP@"
+ECHO="@ECHO@"
+GREP="@GREP@"
+GTAR="@GTAR@"
+MKDIR="@MKDIR@"
+MV="@MV@"
+RM="@RM@"
+SED="@SED@"
+
+progname=`${BASENAME} $0`
+
+while getopts vf: arg; do
+ case $arg in
+ v) verbose=1 ;;
+ f) dat_tar="${OPTARG}" ;;
+ esac
+done
+
+${MKDIR} ${TMPDIR}
+
+if [ -n "$dat_tar" ]; then
+ if ! (${GTAR} -x -C ${TMPDIR} -f $dat_tar readme.txt >/dev/null); then
+ ${ECHO} "$progname: unable to extract readme.txt"
+ ${RM} -rf ${TMPDIR}
+ exit 1
+ fi
+else
+ # Fetch the ReadMe file to read the latest version of the DAT files.
+ if ! (cd ${TMPDIR}; ftp ${DAT_SITE}readme.txt >/dev/null); then
+ ${ECHO} "$progname: unable to fetch ${DAT_SITE}readme.txt"
+ ${RM} -rf ${TMPDIR}
+ exit 1
+ fi
+fi
+
+curver=`${AWK} '/DAT Version/ { print $4; exit }' ${TMPDIR}/readme.txt | ${SED} -e 's/^.*\([0-9][0-9][0-9][0-9]\).*$/\1/'`
+oldver=`${AWK} '/DAT Version/ { print $4; exit }' ${UVSCANDIR}/readme.txt | ${SED} -e 's/^.*\([0-9][0-9][0-9][0-9]\).*$/\1/'`
+
+if [ $curver -le $oldver ]; then
+ if [ -z "$verbose" ]; then
+ ${ECHO} "$progname: VirusScan DAT files are current ($oldver)"
+ fi
+else
+ if [ -z "$dat_tar" ]; then
+ dat_tar=${DAT_SITE}dat-$curver.tar
+ if (cd ${TMPDIR}; ftp $dat_tar >/dev/null); then
+ dat_tar=${TMPDIR}/dat-$curver.tar
+ else
+ ${ECHO} "$progname: unable to fetch $dat_tar"
+ ${RM} -rf ${TMPDIR}
+ exit 1
+ fi
+ fi
+
+ ${GTAR} -x -C ${TMPDIR} -f $dat_tar
+
+ # Backup old dat-* tar files.
+ if [ "`${ECHO} ${UVSCANDIR}/*.tar`" != "${UVSCANDIR}/*.tar" ]; then
+ for file in ${UVSCANDIR}/*.tar; do
+ ${MV} -f $file $file.old
+ done
+ fi
+
+ # Backup old DAT files.
+ for file in ${DAT_FILES}; do
+ file=${UVSCANDIR}/$file
+ if [ -f $file ]; then
+ ${MV} -f $file $file.bak
+ fi
+ done
+
+ # Copy new DAT files into place.
+ for file in ${DAT_FILES}; do
+ ${CP} -f ${TMPDIR}/$file ${UVSCANDIR}/$file
+ done
+ ${CP} -f $dat_tar ${UVSCANDIR}
+ ${RM} -f ${UVSCANDIR}/*.old
+ ${ECHO} `date` Successfully updated VirusScan DAT files to $curver.
+fi
+
+${RM} -rf ${TMPDIR}
+exit 0