#!/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 > /dev/null 2>&1 || true
    	FAILED="false"
	/usr/sbin/update-flashplugin $LOCALFILE > /dev/null 2>&1 || FAILED="true"
	if [ $FAILED = "true" ]; then
		/usr/sbin/update-flashplugin -u > /dev/null 2>&1 || true
		db_text medium flashplugin-nonfree/failed || true
		db_go
	fi
    fi
    db_fset flashplugin-nonfree/local seen false
    db_fset flashplugin-nonfree/httpget seen false
    db_fset flashplugin-nonfree/failed seen false
    ;;
esac

#DEBHELPER#
