[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: Forgive the rant...but



> Feel like sharing with the rest of the class?

Sure, I've attached check_nvidia_module.in.  Our SPEC file replaces
@DRIVERVERSION@ with the version of the driver before putting this file
in /etc/rc.d/init.d.  We have similar init scripts for slmodem, aironet,
vpnclient, etc.  The logic is roughly the same for each one.

/Brian/

-- 
       Brian Long                      |         |           |
       IT Data Center Systems          |       .|||.       .|||.
       Cisco Linux Developer           |   ..:|||||||:...:|||||||:..
       Phone: (919) 392-7363           |   C i s c o   S y s t e m s

#!/bin/sh
##########################################################################
#           Copyright (c) 2002, Cisco Systems, All Rights Reserved
###########################################################################
#
#  File:    check_nvidia_module
#  Date:    02/27/2002
#
###########################################################################
#
# chkconfig: 45 86 14
# description: Tries to compile/install nvidia.o kernel module if it \
#              appears to be missing or the wrong version.
#
###########################################################################
DRIVERDIR="/usr/share/nvidia"
DRIVERVER="@DRIVERVERSION@"
DRIVERMOD="nvidia.o"
MODULEDIR=/lib/modules/`uname -r`/kernel/drivers/video
ID="/usr/bin/id"
WHOAMI=`$ID|sed -e 's/(.*//'`

do_compile () {
	uname -a | grep -q x86_64 && \
		BINARY="NVIDIA-Linux-x86_64-$DRIVERVER*run" || \
		BINARY="NVIDIA-Linux-x86-$DRIVERVER*run"
	cd $DRIVERDIR
	rm -f NVIDIA-Linux-*custom.run
	sh $BINARY --silent --add-this-kernel 2> /dev/null
	sh NVIDIA-Linux-*custom.run  --silent 2> /dev/null
}

change_XF86Config () {
	mv -f /etc/X11/XF86Config /etc/X11/XF86Config.pre_nvidia
	grep -v \"dri\" /etc/X11/XF86Config.pre_nvidia | \
	sed s/\"nv\"/\"nvidia\"/g > /etc/X11/XF86Config
}

do_start () {
	echo -n "Checking for $DRIVERMOD module: "
	if [ "$WHOAMI" != "uid=0" ] ; then
		echo "Failed (super user access required)"
		exit 1
	fi
	if [ -f "$MODULEDIR/$DRIVERMOD" ] ; then
		# There is a module present, was it compiled from this version
		# of the video driver?
		MODVER=`/usr/bin/strings $MODULEDIR/$DRIVERMOD | /bin/awk '/^nvidia id/{print $9}'`
		if [ "$MODVER" != "$DRIVERVER" ]; then
			do_compile
			if [ $? -ne 0 ]; then
				exit 1
			fi
		fi
	else
		do_compile
                if [ $? -ne 0 ]; then
			exit 1
		fi
	fi

	grep -q nvidia /etc/X11/XF86Config || change_XF86Config
}

do_stop () {
	/sbin/modprobe -r nvidia
}

# See how we were called.
case "$1" in
  start)
	do_start
	;;
  status)
	if [ -f "$MODULEDIR/$DRIVERMOD" ] ; then
		echo "$DRIVERMOD kernel module is installed in $MODULEDIR."
	else
		echo "No $DRIVERMOD kernel module exists in $MODULEDIR."
	fi
	;;
  restart)
	do_stop
	do_start
	;;
  stop)
	do_stop
	;;
  *)
	echo "Usage: $0 {start|restart|status}"
	exit 1
esac

exit 0

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]