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

# Uninstall
if [ "$1" = "uninstall" ]; then
echo "ASPEED Graphics Family Solaris U4 XORG driver uninstall begin ...."
rm -f $XF86_DRV_DIR/ast_drv.*
rm -f $XF86_DRV64_DIR/ast_drv.*

test -f ./backup/ast_drv.86 && cp -f ./backup/ast_drv.86   $XF86_DRV_DIR/ast_drv.so
test -f ./backup/ast_drv.64 && cp -f ./backup/ast_drv.64   $XF86_DRV64_DIR/ast_drv.so

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


# Install
echo "ASPEED Graphics Family Solaris U4 XORG driver update begin ...."
rm -rf ./backup
mkdir ./backup
test -f $XF86_DRV_DIR/ast_drv.so && cp -f $XF86_DRV_DIR/ast_drv.so ./backup/ast_drv.86
test -f $XF86_DRV64_DIR/ast_drv.so && cp -f $XF86_DRV64_DIR/ast_drv.so ./backup/ast_drv.64

rm -f $XF86_DRV_DIR/ast_drv.*
rm -f $XF86_DRV64_DIR/ast_drv.*

cp -f ast_drv.86   $XF86_DRV_DIR/ast_drv.so
cp -f ast_drv.64   $XF86_DRV64_DIR/ast_drv.so

echo "ASPEED Graphics Family Solaris U4 XORG driver update finished"

