#!/bin/bash -e
. /usr/share/debconf/confmodule
db_set ubuntu-drivers-common/obsolete-driver false
db_input high ubuntu-drivers-common/obsolete-driver || true

if [ -x /usr/bin/nvidia-detector ]; then
    LATEST=$(nvidia-detector)
    if [ ${LATEST} ] && [ "${LATEST}" != "none" ]; then
        db_fset ubuntu-drivers-common/obsolete-driver seen false
        db_subst ubuntu-drivers-common/obsolete-driver latest $LATEST
        db_input high ubuntu-drivers-common/obsolete-driver || true
        db_go || true
    fi
fi
