From: Michael Prokop Date: Mon, 11 Jun 2007 10:17:58 +0000 (+0200) Subject: Do not overwrite existing info.tar.bz2 files but use timestamp in filename instead X-Git-Tag: 0.3.4~6 X-Git-Url: http://git.grml.org/?p=grml-hwinfo.git;a=commitdiff_plain;h=b7cd41bfdd638dd5306cc85cc8599677d7bf9e92 Do not overwrite existing info.tar.bz2 files but use timestamp in filename instead --- diff --git a/debian/changelog b/debian/changelog index 655ea0a..b99c347 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ grml-hwinfo (0.3-3) unstable; urgency=low [Michael Prokop] * Improve code layout (like checks for binaries, portability for non-grml system). + * Do not overwrite existing info.tar.bz2 files but use timestamp + in filename instead. [Alexander Wirt] * Add procinfo to suggests. diff --git a/grml-hwinfo b/grml-hwinfo index 29c898e..b96d2e8 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -4,7 +4,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Mon Jun 11 12:05:32 CEST 2007 [mika] +# Latest change: Mon Jun 11 12:15:04 CEST 2007 [mika] ################################################################################ # Notice: Some ideas have been taken from # http://club.black.co.at/david/hwdb/infodump @@ -12,12 +12,12 @@ ################################################################################ # variables -UNAME=$(uname -r) -PN=$(basename $0) +UNAME="$(uname -r)" +PN="$(basename $0)" VERSION='0.3' -if [ -z "$INFOFILE" ]; then - INFOFILE='info.tar.bz2' -fi + +[ -n "$INFOFILE" ] || INFOFILE='info.tar.bz2' + if [ "$(id -u)" != 0 ] ; then NOTROOT=1 @@ -181,7 +181,14 @@ fi ) # finally create the tarball -tar jcf $INFOFILE info/ && rm -Rf info/ +if [ -f "$INFOFILE" ] ; then + DATE="$(date +%Y%m%d_%H:%M:%S)" + INFOFILE="info_$DATE.tar.bz2" + echo "Warning: $INFOFILE exists already, using $INFOFILE instead.">&1 + tar jcf $INFOFILE info/ && rm -Rf info/ +else + tar jcf $INFOFILE info/ && rm -Rf info/ +fi echo [ -r "$INFOFILE" ] && echo "$INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) has been generated."