# Set Variables 
XF86_LIB_DIR="/usr/X11/lib/modules"
XF86_DRV_DIR="/usr/X11/lib/modules/drivers"

# Uninstall
if [ "$1" = "uninstall" ]; then
echo "ASPEED Graphics Family Solaris XORG driver uninstall begin ...."
rm -f $XF86_DRV_DIR/ast_drv.*
rm -f $XF86_LIB_DIR/libddc.*
rm -f $XF86_LIB_DIR/libfb.*
rm -f $XF86_LIB_DIR/libint10.*
rm -f $XF86_LIB_DIR/libramdac.*
rm -f $XF86_LIB_DIR/libvbe.*
rm -f $XF86_LIB_DIR/libvgahw.*
rm -f $XF86_LIB_DIR/libxaa.*

test -f ./backup/ast_drv.* && cp -f ./backup/ast_drv.*   $XF86_DRV_DIR/
cp -f ./backup/libddc.a    $XF86_LIB_DIR/libddc.a
cp -f ./backup/libfb.a     $XF86_LIB_DIR/libfb.a
cp -f ./backup/libint10.a  $XF86_LIB_DIR/libint10.a
cp -f ./backup/libramdac.a $XF86_LIB_DIR/libramdac.a
cp -f ./backup/libvbe.a    $XF86_LIB_DIR/libvbe.a
cp -f ./backup/libvgahw.a  $XF86_LIB_DIR/libvgahw.a
cp -f ./backup/libxaa.a    $XF86_LIB_DIR/libxaa.a

rm -rf ./backup
echo "ASPEED Graphics Family Solaris XORG driver Uninstall Finished"
exit 0
fi


# Install
echo "ASPEED Graphics Family Solaris XORG driver update begin ...."
rm -rf ./backup
mkdir ./backup
test -f $XF86_DRV_DIR/ast_drv.* && cp -f $XF86_DRV_DIR/ast_drv.* ./backup
cp -f $XF86_LIB_DIR/libddc.* ./backup
cp -f $XF86_LIB_DIR/libfb.* ./backup
cp -f $XF86_LIB_DIR/libint10.* ./backup
cp -f $XF86_LIB_DIR/libramdac.* ./backup
cp -f $XF86_LIB_DIR/libvbe.* ./backup
cp -f $XF86_LIB_DIR/libvgahw.* ./backup
cp -f $XF86_LIB_DIR/libxaa.* ./backup

rm -f $XF86_DRV_DIR/ast_drv.*
rm -f $XF86_LIB_DIR/libddc.*
rm -f $XF86_LIB_DIR/libfb.*
rm -f $XF86_LIB_DIR/libint10.*
rm -f $XF86_LIB_DIR/libramdac.*
rm -f $XF86_LIB_DIR/libvbe.*
rm -f $XF86_LIB_DIR/libvgahw.*
rm -f $XF86_LIB_DIR/libxaa.*

cp -f ast_drv.o   $XF86_DRV_DIR/ast_drv.o
cp -f libddc.a    $XF86_LIB_DIR/libddc.a
cp -f libfb.a     $XF86_LIB_DIR/libfb.a
cp -f libint10.a  $XF86_LIB_DIR/libint10.a
cp -f libramdac.a $XF86_LIB_DIR/libramdac.a
cp -f libvbe.a    $XF86_LIB_DIR/libvbe.a
cp -f libvgahw.a  $XF86_LIB_DIR/libvgahw.a
cp -f libxaa.a    $XF86_LIB_DIR/libxaa.a

echo "ASPEED Graphics Family Solaris XORG driver update finished"

