#!/bin/sh

set -e

. /usr/share/debconf/confmodule

FILE=/root/tmp/HyperSpec-7-0.tar.gz

check_archive()
{    
    # check if the file is ok
    if [ -s "$FILE" ] && \
	gzip --test --quiet  "$FILE" > /dev/null 2>&1 ; then
	true
    else
	false
    fi
}


if test "$1" = "reconfigure" ; then
    db_reset hyperspec/downloading
fi

case "$1" in
    configure|reconfigure)
	if ! check_archive ; then
	    db_input medium hyperspec/downloading || true
	    db_go || true
	fi
	;;
    *) 
	echo "config called with invalid option" >&2
	exit 0
	;;
esac

exit 0
