#!/bin/bash
########################################################
### /usr/sbin/ruby_NVinstaller ###
### for usage call it with -h or --help parameter ###
########################################################
if [[ -z $1 ]] || [ "$1" == "-h" ] || [ "$1" == "--help" ] ;then
echo
echo "Usage :"
echo "$0 full path to Nvidia installer"
echo "eg. $0 /root/NVIDIA-Linux-x86-1.0-4349.run"
exit 1
fi
if [[ -z $OPENWINHOME ]];then
echo
echo "OPENWINHOME not defined!!!"
echo "Please set the environment variable OPENWINHOME"
echo "pointing to your XFree prefix eg. /usr/X11R6"
echo "for bash shell :"
echo "export OPENWINHOME=/usr/X11R6"
exit 1
fi
cd $OPENWINHOME
echo
echo "backup file for XFree's GL libraries "
echo "is $OPENWINHOME/libGL-backup.tar"
if [ -x libGL-backup.tar ]; then
echo "old backup exist, deleting" && rm libGL-backup.tar
fi
echo
find lib -name "libGL.*" -o -name "libGLcore*" \
-o -name "libglx.*" | xargs tar rpf libGL-backup.tar \
&& echo "backup finished"
echo
echo "now running Nvidia installer"
echo "`which $1` --no-opengl-headers --xfree86-prefix=/usr/X11R6NV --opengl-prefix=/usr/X11R6NV"
echo
`which $1` --no-opengl-headers --xfree86-prefix=/usr/X11R6NV --opengl-prefix=/usr/X11R6NV
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo
echo "Nvidia installer finished,"
echo "now coping files to /usr/X11R6/libNV/"
echo
cd /usr/X11R6NV/lib && tar c * | tar xvC /usr/X11R6/libNV/
echo
echo "restoring backuped GL libraries"
echo
cd $OPENWINHOME
tar xvfp libGL-backup.tar && ldconfig && echo "GL libraries restored" && rm libGL-backup.tar
fi
if [ $RETVAL -ne 0 ]; then
echo
echo "installer aborted, not restoring backup"
echo "deleting backup files" && rm libGL-backup.tar
fi
echo
echo "script finished"
|