+UNAME="$(uname -r)"
+PN="$(basename $0)"
+[ -n "$WORKING_DIR" -a -d "$WORKING_DIR" ] || WORKING_DIR=$(pwd)
+VERSION='0.4.1'
+TIMESTAMP='+%F--%H-%M-%S-%Z'
+TIMESTAMP_NANO='+%F--%H-%M-%S-%N-%Z'
+
+GENERATE_FILE='1'
+GENERATE_DIRECTORY=''
+
+while getopts "hdf" args; do
+ case "$args" in
+ h) echo "$PN - collect hardware information
+
+This tool collects information of the hardware this tool is being executed
+on. It can be executed as normal user to collect some basic information or
+with root permissions to collect as much information as possible. By
+default, a file named grml-hwinfo-TIMESTAMP.tar.bz2 storing all collected
+information will be created in the current working directory. Alternatively,
+you can have it create a directory with all information.
+
+Options:
+
+-h : Display this help
+-f : Create grml-hwinfo-TIMESTAMP.tar.bz2
+-d : Create grml-hwinfo-TIMESTAMP/
+
+-df : Create both, the directory and the file
+"
+
+ exit 0;;
+
+ d)
+ GENERATE_FILE=''
+ GENERATE_DIRECTORY='1'
+ ;;
+
+ f) # generating file; default behaviour
+ GENERATE_FILE='1'
+ ;;
+
+ esac
+ done
+
+
+TMPDIR=$(mktemp -d) || { echo "Error creating a temporary directory, can not continue. Exiting.">&2 ; exit 1; }
+INFODIR="info"
+
+bailout() {
+ [ -d "$TMPDIR" ] && rm -rf "$TMPDIR"
+ [ -n "$1" ] && exit 1 || exit 0
+}
+
+DATE="$(date $TIMESTAMP)"
+[ -n "$INFOFILE" ] || INFOFILE="grml-hwinfo-$DATE.tar.bz2"
+INFOFILE="${WORKING_DIR}/${INFOFILE}"
+[ -n "$INFOOUTDIR" ] || INFOOUTDIR="grml-hwinfo-$DATE"
+INFOOUTDIR="${WORKING_DIR}/${INFOOUTDIR}"