#!/bin/sh

set -e

. /usr/share/debconf/confmodule

case "$1" in
    configure*)
    db_get flashplugin-nonfree/local
    if [ -d "$RET" -a -f "$RET"/install_flash_player_7_linux.tar.gz ]; then
	LOCALFILE="-l $RET"
	INSTALL="true"
    fi
    if [ -z "$LOCALFILE" ]; then
	db_get flashplugin-nonfree/httpget
	if [ "$RET" = "true" ]; then
	    INSTALL=$RET
	fi
    fi
    if [ "$INSTALL" = "true" ]; then
	/usr/sbin/update-flashplugin -u || true
    	FAILED="false"
	/usr/sbin/update-flashplugin $LOCALFILE || FAILED="true"
	if [ $FAILED = "true" ]; then
		/usr/sbin/update-flashplugin -u || true
	fi
    fi
    db_fset flashplugin-nonfree/local seen false
    db_fset flashplugin-nonfree/httpget seen false
    ;;
esac

#DEBHELPER#
