#!/bin/sh

set -e

. /usr/share/debconf/confmodule

case "$1" in
    configure*)
    db_get nvidia-cg-toolkit/local
    if [ -d "$RET" ]; then
        LOCALDIR="--search-path $RET"
        INSTALL="true"
    fi
    if [ -z "$LOCALDIR" ]; then
    db_get nvidia-cg-toolkit/httpget
    if [ "$RET" = "true" ]; then
        INSTALL=$RET
        db_get nvidia-cg-toolkit/http_proxy
        if [ $RET ]; then
            HTTP_PROXY="--proxy $RET"
        fi
    fi
    fi
    db_get nvidia-cg-toolkit/delete
    if [ "$RET" = "true" ]; then
        DELETE="--delete-after"
    fi

    if [ "$INSTALL" = "true" ]; then
        nvidia-cg-toolkit-installer --install $DELETE $LOCALDIR $HTTP_PROXY || true
    fi
    ;;
esac

#DEBHELPER#
