#!/bin/bash

base_dir="/opt/hp/graphics/ati"
version=`uname -r`
mod_dir="/lib/modules/${version}/kernel/drivers/char/drm"

# Make sure user is root
if [[ `whoami` != "root" ]]
then
    echo ""
    echo "ERROR: You must be root to run this script."
    echo ""
    exit
fi

echo "Unconfiguring FireGL accelerated driver..."

# Remove modules:
echo "- Deleting fglrx modules..."
rm -f ${mod_dir}/fglrx.*
rm -f /lib/modules/fglrx/*.o
rm -f /lib/modules/fglrx/*.ko
rm -f /lib/modules/fglrx/build_mod/2.6.x/*.o
rm -f /lib/modules/fglrx/build_mod/2.6.x/*.ko

# Make 'atimodconfig' inactive:
/sbin/chkconfig --del atimodconfig > /dev/null

# Restore of X config files not necessary since
# aticonfig just adds a 'fglrx' device and screen
# section, VESA stuff should still work. 

# Remove soft link to documentation
cd ${base_dir}
if [ -h ati-docs ]; then
   rm -f ati-docs
fi

# clean up 
modprobe -r fglrx

echo "- COMPLETE."

exit 0;
