aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRobert Buchholz <rbu@gentoo.org>2007-12-14 23:30:40 +0000
committerRobert Buchholz <rbu@gentoo.org>2007-12-14 23:30:40 +0000
commitc5027a21129f17e280ba5089166cb40d209b17de (patch)
tree81c792c322345b2eee5b65d066224768a919eb2d /bin
parentExtracted emul code copies to own file (diff)
downloadsecurity-c5027a21129f17e280ba5089166cb40d209b17de.tar.gz
security-c5027a21129f17e280ba5089166cb40d209b17de.tar.bz2
security-c5027a21129f17e280ba5089166cb40d209b17de.zip
New version of the update script: introduces --quiet, --verbose and --full
svn path=/; revision=188
Diffstat (limited to 'bin')
-rwxr-xr-xbin/update57
1 files changed, 46 insertions, 11 deletions
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