#!/bin/sh
#

verify() {
    # Delete previous sig file!
    rm "$1.sig"
    /usr/bin/wget -q -c -O $1.sig $2.sig || return 1
    /usr/bin/wget -q -c -O $1 $2 || return 1
    gpg --no-verbose --quiet --verify "$1.sig" || return 1
    return 0
}

case $(basename "$2") in
    "gb-pkg.db.tar.gz")
	verify $1 $2 || exit 1 
	;;
    *)
	/usr/bin/wget -q --passive-ftp -c -O $1 $2 || exit 1
esac

exit 0

# This could be the real thing
case $(basename "$2") in
    "core.db.tar.gz")
	#verify $1 $2 || exit 1 
	;;
    "extra.db.tar.gz")
	#verify $1 $2 || exit 1 
	;;
    "community.db.tar.gz")
	#verify $1 $2 || exit 1 
	;;
    "testing.db.tar.gz")
	verify $1 $2 || exit 1 
	;;
    *)
	/usr/bin/wget -q --passive-ftp -c -O $1 $2 || exit 1
esac