#!/bin/sh

# Install the appropriate proprietary graphics driver.
#
# Take advantage of language-installer's 'Please wait'
# dialog

FILEDIR=/usr/share/keremeos-config
ARCHIVE=/archive

# Install nVidia proprietary driver if necessary.
# Assumes nVidia card should be active if the hardware is present
# We do things this way (instead of w/ Jockey) to avoid
# network access and potentially slow apt-get updates
# during firstboot
DETECT="$(lspci | grep VGA | grep -i nvidia)"
COUNT=$(echo "$DETECT" | grep -c -i nvidia)
if [ $COUNT -ne 0 ]; then
    cp ${FILEDIR}/xorg-nvidia.conf /etc/X11/xorg.conf
    
    # Seed jockey cache
    mkdir -p /var/cache/jockey
    cp ${FILEDIR}/jockey/* /var/cache/jockey

    # Install nvidia drivers
    dpkg -i ${ARCHIVE}/nvidia*185*.deb ${ARCHIVE}/nvidia-settings*.deb
fi
