From c5027a21129f17e280ba5089166cb40d209b17de Mon Sep 17 00:00:00 2001 From: Robert Buchholz Date: Fri, 14 Dec 2007 23:30:40 +0000 Subject: New version of the update script: introduces --quiet, --verbose and --full svn path=/; revision=188 --- bin/update | 57 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/update b/bin/update index bed1e6d..b9c9f8e 100755 --- a/bin/update +++ b/bin/update @@ -6,33 +6,68 @@ if [ ! -d data ]; then exit 1 fi +TEMP=`getopt -o fqv --long full,quiet,verbose -n 'update' -- "$@"` + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +# Note the quotes around `$TEMP': they are essential! +eval set -- "$TEMP" + +FULL="" +#MAIL="" +QUIET="" +VERB="-nv" + +while true ; do + case "$1" in + -f|--full) FULL="1" ; shift ;; +# -m|--mail) MAIL="1" ; shift ;; + -q|--quiet) QUIET="1" ; shift ;; + -v|--verbose) VERB="" ; shift ;; + --) shift ; break ;; + *) echo "Internal error." ; exit 1 ;; + esac +done + +if [ -n "${QUIET}" ] ; then + # stder->stdout + 2>&1 + # stdout = null + exec 1<>/dev/null +fi + + # Update all cached files mkdir -p cache cd cache rm -f allitems.html{,.gz} echo "[DOWNLOAD] MITRE Master database" -wget -nv http://cve.mitre.org/data/downloads/allitems.html.gz +wget ${VERB} http://cve.mitre.org/data/downloads/allitems.html.gz gunzip allitems.html.gz echo "===============================================================================" echo "[DOWNLOAD] NVD Last Modified file" -wget --timestamping -nv http://nvd.nist.gov/download/nvdcve-modified.xml +wget --timestamping ${VERB} http://nvd.nist.gov/download/nvdcve-modified.xml -echo "===============================================================================" -YEAR=`date +"%Y"` -echo "[DOWNLOAD] NVD Database 2002..${YEAR}" -for yr in `seq 2002 ${YEAR}`; do - wget --timestamping -nv http://nvd.nist.gov/download/nvdcve-$yr.xml -done +if [ -n "${FULL}" ] ; then + echo "===============================================================================" + YEAR=`date +"%Y"` + echo "[DOWNLOAD] NVD Database 2002..${YEAR}" + for yr in `seq 2002 ${YEAR}`; do + wget --timestamping ${VERB} http://nvd.nist.gov/download/nvdcve-$yr.xml + done +fi echo "===============================================================================" echo "[UPDATE] Updating our CVE data" +NEWLIST="$(mktemp -t cveupdate.XXXXXXXXX)" + # Run the update script cd ../data/CVE/ -../../bin/updatelist ../../cache/allitems.html ../../cache/nvdcve-modified.xml list > list.new +../../bin/updatelist ../../cache/allitems.html ../../cache/nvdcve-modified.xml list > "${NEWLIST}" echo "===============================================================================" echo "[DIFF] New and updated CVE entries" -diff -u list list.new || true -mv -f list.new list +diff -u list ${NEWLIST} || true +mv -f "${NEWLIST}" list -- cgit v1.2.3-65-gdbad