#!/bin/sh UNSUPPORTED=1 LEGACY=0 #CARDS="$(lspci -n|gawk '{sub("Class","")} $2 == "0300:" {print$3}')" CARDS="$(lspci -n|perl -e 'while(<>){(push(@cards,$_)) if (s/^.+?\s*0300\:\s+(.+?)\s+.*$/$1/)} print join(" ",@cards);')" for card in $CARDS; do VENDOR=${card%:*} DEVICE=${card#*:} case $VENDOR in 10de|12d2) case $DEVICE in 0008|0009|0010|0018|0019) UNSUPPORTED=1 ;; 0020|0028|0029|002c|002d|00a0|0100|0101|0103|0150|0151|0152|0153) LEGACY=1;UNSUPPORTED=0 ;; 0110|0111|0112|0113|0170|0171|0172|0173|0174|0175|0176|0177|0178|0179|017a|017c|017d|0181|0182|0183|0185|0188|018a|018b|018c|01a0|01f0|0200|0201|0202|0203|0250|0251|0253|0258|0259|025b|0280|0281|0282|0286|0288|0289|028c) LEGACY=2;UNSUPPORTED=0 ;; #0170) LEGACY=1;UNSUPPORTED=0 ;; # GeForce4 MX 460 workaround *) UNSUPPORTED=0 ;; esac ;; esac done if [ ! -f /etc/kanotix-version ]; then echo Error: No KANOTIX found. Do not ask for support! >&2 fi if [ ! -f /etc/debian_version ]; then echo Error: No Debian compatible system found. Do not ask for support! >&2 exit 100 fi if [ "$UNSUPPORTED" = "1" ]; then echo Error: No supported nVidia VGA adapter found. >&2 exit 3 fi if [ "$(id -u)" != "0" ]; then echo Error: You must be root to run this script! >&2 exit 4 fi [ -d /KNOPPIX -o -d /KANOTIX ] && INSTALLED="no" || INSTALLED="yes" if [ -f /etc/default/distro ]; then . /etc/default/distro [ "$FLL_DISTRO_MODE" = "live" ] && INSTALLED="no" fi if [ "$INSTALLED" = "yes" ]; then if [ -n "$DISPLAY" ]; then echo Error: Can\`t be run within X! Use a text console \(ALT-CTRL-F1\) >&2 exit 5 fi else if grep -q -e unionfs -e aufs /proc/mounts; then echo Unionfs found. >&2 else echo Activating Unionfs now. >&2 mkdir -p /tmp/union UNION=/KNOPPIX [ -d /KANOTIX ] && UNION=/KANOTIX [ -d "$FLL_MOUNTPOINT" ] && UNION="$FLL_MOUNTPOINT" mount -t unionfs -o dirs=/tmp/union/:$UNION /none $UNION/ >/dev/null 2>&1 fi fi X_CONF=XF86Config-4 if which Xorg >/dev/null; then [ -e /etc/X11/xorg.conf ] && X_CONF=xorg.conf fi AGPRATE=0 # AGPRATE can be 15 (8x), 4, 2, 1 or 0 (auto) FW=0 # FW can be 0 (off) or 1 (on) EMUL=1 COMPOSITE=1 NRC=1 USEEDID=1 USEEDIDFREQS=1 RMML=0 XVMC=1 TV=0 DYN_TWINVIEW=0 VER_FORCE="" PRINT_VER=0 NO_X_KILL=0 while getopts cdefnprtlqxv:zh opt; do case $opt in c) COMPOSITE=0 ;; d) DYN_TWINVIEW=1 ;; e) USEEDID=0 ;; f) FW=1 ;; n) NRC=0 ;; p) PRINT_VER=1 ;; r) RMML=1 ;; t) TV=1 ;; l) EMUL=0 ;; q) USEEDIDFREQS=0 ;; x) XVMC=0 ;; v) VER_FORCE="$OPTARG" ;; z) NO_X_KILL=1 ;; \?|h) echo "Usage $0 [options] " >&2 echo "optional options are:" >&2 echo " -c Disable Composite extension" >&2 echo " -d Enable DynamicTwinView" >&2 echo " -e Disable UseEDID" >&2 echo " -f Enable FastWrites" >&2 echo " -n Disable DFP Native Resolution Check" >&2 echo " -r Remove ModeLines" >&2 echo " -t Enable TV-Out" >&2 echo " -q Disable UseEdidFreqs" >&2 echo " -x Disable XvMC" >&2 echo " -l Disable 32 bit emulation libs in 64 bit mode" >&2 echo " -v VER Force use of specific driver build. Example: -v 1.0-9629" >&2 echo " -p Print driver version to be installed and quit" >&2 echo " -z No X kill/restart. Special purpose only!" >&2 echo " -h Show this help" >&2 exit 6 ;; esac done # check for pipe usage [ "$0" = "sh" -o "$0" = "bash" ] && NO_X_KILL=1 # old DX7 cards up to gf2gts/pro VER_LEGACY_1=1.0-7185 # DX7 cards since gf2mx and all DX8 cards VER_LEGACY_2=1.0-9631 VER=100.14.03 #VER=1.0-9755 #VER=1.0-9746 #VER=1.0-9742 #VER=1.0-9631 #VER=1.0-9629 #VER=1.0-9626 #VER=1.0-9625 #VER=1.0-8776 #VER=1.0-8774 #VER=1.0-8762 #VER=1.0-8756 #VER=1.0-8178 #VER=1.0-8174 #VER=1.0-7676 #VER=1.0-7667 #VER=1.0-7664 #VER=1.0-7185 #VER=1.0-7184 #VER=1.0-7182 #VER=1.0-7174 #VER=1.0-7167 #VER=1.0-6629 #VER=1.0-6111 #VER=1.0-6106 #VER=1.0-5336 #VER=1.0-5328 #VER=1.0-4620 [ "$VER" = "1.0-8776" -a "$COMPOSITE" = "1" ] && VER=1.0-9631 case $VER in 1.0-7664|1.0-7667|1.0-7676|1.0-8174|1.0-8178|1.0-8756|1.0-8762|1.0-8774|1.0-8776|1.0-9625|1.0-9626|1.0-9629|1.0-9631) [ "$LEGACY" = "1" ] && VER=$VER_LEGACY_1 ;; 1.0-9742|1.0-9746|1.0-9755|100.14.03) if [ "$LEGACY" = "1" ]; then VER=$VER_LEGACY_1 elif [ "$LEGACY" = "2" ]; then VER=$VER_LEGACY_2 fi ;; esac ARCH="" [ "$(uname -m)" = "x86_64" ] && ARCH="_64" [ "$VER" = "1.0-7664" -a "$ARCH" = "_64" ] && VER=1.0-7184 if [ -n "$VER_FORCE" ]; then if [ "${#VER_FORCE}" = "4" ]; then VER=1.0-$VER_FORCE else VER=$VER_FORCE fi fi if [ "$PRINT_VER" = "1" ]; then echo $VER exit fi DVER=1.0.${VER#1.0-} SERVER=de.download.nvidia.com [ "$VER" = "1.0-9742" ] && SERVER=us.download.nvidia.com URL=http://$SERVER/XFree86/Linux-x86$ARCH/$VER/ EURL=http://$SERVER/XFree86/Linux-x86/$VER/ PKG=0 PATCH=0 HACK=0 UDEVHACK=0 [ "$VER" = "1.0-7174" ] && UDEVHACK=1 KVER=$(uname -r) KV=$(uname -r|cut -d. -f1-2) cd /usr/src [ -f NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG.run ] || wget -Nc "$URL"NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG.run rm -rf NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG bash NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG.run --extract-only >/dev/null 2>&1 || ( rm -f NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG.run echo NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG.run could not be extracted >&2 echo and has been deleted. Please restart this script. >&2 exit 1 ) || exit $? if [ "$ARCH" = "_64" -a "$EMUL" = "1" ]; then [ -f NVIDIA-Linux-x86-$VER-pkg$PKG.run ] || wget -Nc "$EURL"NVIDIA-Linux-x86-$VER-pkg$PKG.run rm -rf NVIDIA-Linux-x86-$VER-pkg$PKG bash NVIDIA-Linux-x86-$VER-pkg$PKG.run --extract-only >/dev/null 2>&1 || ( rm -f NVIDIA-Linux-x86-$VER-pkg$PKG.run echo NVIDIA-Linux-x86-$VER-pkg$PKG.run could not be extracted >&2 echo and has been deleted. Please restart this script. >&2 exit 2 ) || exit $? fi if [ "$KV" = "2.6" -a "$PATCH" = "1" ]; then wget -Nc http://www.minion.de/files/NVIDIA_kernel-$VER-2.6.diff fi if [ -f /etc/modutils/1alsa ]; then mv /lib/modules/extra/alsa /lib/modules/`uname -r`/ rm -f /etc/modutils/1alsa depmod -a fi if ! [ "$NO_X_KILL" = "1" ]; then if [ "$INSTALLED" = "yes" ]; then DM=$(cat /etc/X11/default-display-manager 2>/dev/null) DM=$(basename $DM 2>/dev/null) if [ -z "$DM" ]; then if [ -x /etc/init.d/kdm ]; then /etc/init.d/kdm stop elif [ -x /etc/init.d/gdm ]; then /etc/init.d/gdm stop elif [ -x /etc/init.d/xdm ]; then /etc/init.d/xdm stop fi else [ -x /etc/init.d/$DM ] && /etc/init.d/$DM stop fi fi fi killall -9 Xgl >/dev/null 2>&1 rmmod nvidia >/dev/null 2>&1 rm -f /lib/modules/`uname -r`/kernel/drivers/video/nvidia.*o rm -f /lib/modules/`uname -r`/volatile/nvidia.*o rm -f /usr/local/bin/nvidia-settings /usr/local/bin/nvidia-xconfig OLD_NVIDIA=$(COLUMNS=200 dpkg -l|cut -f3 -d' '|grep nvidia) [ -n "$OLD_NVIDIA" ] && dpkg --purge $OLD_NVIDIA # Ubuntu workaround [ -f /etc/default/linux-restricted-modules-common ] && perl -pi -e 's/^(DISABLED_MODULES)=.*/\1="nv"/' /etc/default/linux-restricted-modules-common unset UP if ! [ -x /usr/bin/module-assistant ]; then apt-get update && UP=1 apt-get install --allow-unauthenticated --yes module-assistant fi if ! [ -d /usr/share/build-essential ]; then [ -z "$UP" ] && apt-get update apt-get install --allow-unauthenticated --yes build-essential fi if ! [ -x /usr/bin/module-assistant ]; then echo "Error: module-assistant missing." >&2 [ -r /etc/lsb-release ] && . /etc/lsb-release [ "$DISTRIB_ID" = "Ubuntu" ] && echo "Hint: Enable universe repository in /etc/apt/sources.list." >&2 exit 1 fi # Debian (and Ubuntu) [ -f /etc/debian_version -a ! -f /etc/kanotix-version ] && m-a -i prepare cd NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG if [ "$KV" = "2.6" ]; then if [ "$PATCH" = "1" ]; then cd usr/src/nv patch -p1 < ../../../../NVIDIA_kernel-$VER-2.6.diff ln -s Makefile.kbuild Makefile cd ../../.. fi else # fix NVIDIA's stupid error in Makefile perl -pi -e 's/"\$\$\?"/"\$\?"/' Makefile fi [ "$(uname -r|cut -d- -f1)" = "2.6.10" ] && perl -pi -e s/pci_find_class/pci_get_class/ usr/src/nv/nv.c if [ "$(uname -r|grep -E '2.6.11')" != "" -a "$VER" = "1.0-6629" ]; then #PATCH_BASE_URL="http://www.minion.de/files/1.0-6629/" PATCH_BASE_URL="http://kanotix.com/files/1.0-6629/" PATCHES="NVIDIA_kernel-1.0-6629-1155389.diff NVIDIA_kernel-1.0-6629-1161283.diff NVIDIA_kernel-1.0-6629-1165235.diff NVIDIA_kernel-1.0-6629-1171869.diff NVIDIA_kernel-1.0-6629-1175225.diff NVIDIA_kernel-1.0-6629-1182399.diff NVIDIA_kernel-1.0-6629-1189413.diff NVIDIA_kernel-1.0-6629-1201042.diff" for p in $PATCHES; do #wget -qO- $PATCH_BASE_URL$p|patch -p0 [ -f /usr/src/$p ] || wget -NqO/usr/src/$p $PATCH_BASE_URL$p patch -p0 /dev/null elif [ -f /usr/lib/libnvidia-tls.so.1 ]; then ./nvidia-installer --uninstall -s -N 2>/dev/null fi if [ -d /usr/lib/xorg/modules ]; then #CC=$CC ./nvidia-installer -s --x-module-path=/usr/lib/xorg/modules -N 2>/dev/null else #CC=$CC ./nvidia-installer -s -N 2>/dev/null fi fi cd .. rm -rf NVIDIA-Linux-x86$ARCH-$VER-pkg$PKG rm -f /etc/modutils/nvidia perl -pi -e 's|.*char-major-195.*[\n]?||' /etc/modutils/aliases perl -pi -e 's|[\n]?$|\n|' /etc/modutils/aliases echo alias char-major-195 nvidia >> /etc/modutils/aliases depmod -a if ! [ -e /etc/X11/$X_CONF.1st ]; then cp /etc/X11/$X_CONF /etc/X11/$X_CONF.1st fi perl -p -e 's/^[\s]*Load\s*"GLcore"/#\tLoad "GLcore"/; s/^[\s]*Load\s*"dri"/#\tLoad "dri"/; s/^[\s]*#*[\s]*Load\s*"glx"/\tLoad "glx"/; s/^[\s]*Driver\s*"nv"/\tDriver "nvidia"/g; s/^[\s]*Driver\s*"fbdev"/\tDriver "nvidia"/g; s/^[\s]*Driver\s*"vesa"/\tDriver "nvidia"/g; s/DefaultColorDepth.*/DefaultColorDepth 24/; s/^[\s]*Option\s*"sw_cursor"/\t#Option "sw_cursor"/; s/^.*IgnoreDisplayDevices.*\n?//g; s/^.*Coolbits.*\n?//g; s/^([\s]*Driver\s*"nvidia")/\1\n\tOption "IgnoreDisplayDevices"\t"TV"\n\tOption "Coolbits"\t"1"/g' \ < /etc/X11/$X_CONF.1st > /etc/X11/$X_CONF if which Xorg >/dev/null; then perl -pi -e 's/^.*RenderAccel.*\n?//g;s/^.*AllowGLXWithComposite.*\n?//g;s/^.*RandRRotation.*\n?//g; s/^.*AddARGBGLXVisuals.*\n?//g;s/^.*DisableGLXRootClipping.*\n?//g;s/^.*TripleBuffer.*\n?//g; s/^.*UseEDID.*\n?//g;s/^.*UseEdidFreqs.*\n?//g;s/^.*DynamicTwinView.*\n?//g;s/^.*ModeValidation.*\n?//g; s/^([\s]*Driver\s*"nvidia")/\1\n\tOption "RenderAccel"\t"1"\n\tOption "AllowGLXWithComposite"\t"1"\n\tOption "RandRRotation"\t"1"\n\tOption "AddARGBGLXVisuals"\t"1"\n\tOption "DisableGLXRootClipping"\t"1"\n\tOption "TripleBuffer"\t"1"\n\tOption "UseEDID"\t"1"\n\tOption "UseEdidFreqs"\t"1"\n\tOption "DynamicTwinView"\t"0"\n#\tOption "ModeValidation"\t"NoDFPNativeResolutionCheck"/g' /etc/X11/$X_CONF if ! grep -q Extensions /etc/X11/$X_CONF; then printf "%b\n" '\nSection "Extensions"' >> /etc/X11/$X_CONF printf "%b\n" '\tOption\t"Composite"\t"1"' >> /etc/X11/$X_CONF printf "%b\n" '#\tOption\t"RENDER"\t"1"' >> /etc/X11/$X_CONF echo 'EndSection' >> /etc/X11/$X_CONF fi perl -pi -e 's/^[\s]*#*[\s]*Option\s*"Composite".*/\tOption\t"Composite"\t"1"/' /etc/X11/$X_CONF # disable composite for cards without dx9 support for card in $CARDS; do DEVICE=${card#*:} case $DEVICE in 0020|0028|0029|002c|002d|00a0|00ff|0100|0101|0103|0110|0111|0112|0113|0150|0151|0152|0153|0170|0171|0172|0173|0174|0175|0176|0177|0179|017a|017d|0178|017c|0181|0182|0183|0185|0188|018c|018a|018b|01a0|01f0|0200|0201|0202|0203|0250|0251|0253|0258|0259|025b|0280|0281|0282|0286|0288|0289|028c) #perl -pi -e 's/^[\s]*#*[\s]*Option\s*"Composite".*/#\tOption\t"Composite"\t"1"/' /etc/X11/$X_CONF #perl -pi -e 's/^.*RenderAccel.*\n?//g;s/^.*AllowGLXWithComposite.*\n?//g;s/^.*RandRRotation.*\n?//g' /etc/X11/$X_CONF ;; #perl -pi -e 's/^(.*RenderAccel"\s*).*/\1"1"/g;s/^.*AllowGLXWithComposite.*\n?//g;s/^.*RandRRotation.*\n?//g; # s/^.*AddARGBGLXVisuals.*\n?//g;s/^.*DisableGLXRootClipping.*\n?//g;s/^.*TripleBuffer.*\n?//g' /etc/X11/$X_CONF perl -pi -e 's/^(.*RenderAccel"\s*).*/\1"0"/g' /etc/X11/$X_CONF ;; esac done # disable composite if not -c option used [ "$COMPOSITE" = "0" ] && perl -pi -e 's/^[\s]*#*[\s]*Option\s*"Composite".*/#\tOption\t"Composite"\t"1"/' /etc/X11/$X_CONF # disable UseEDID if -e option used [ "$USEEDID" = "0" ] && perl -pi -e 's/^(.*UseEDID"\s*).*/\1"0"/g' /etc/X11/$X_CONF # disable UseEdidFreqs if -q option used [ "$USEEDIDFREQS" = "0" ] && perl -pi -e 's/^(.*UseEdidFreqs"\s*).*/\1"0"/g' /etc/X11/$X_CONF # remove modelines if -r option used [ "$RMML" = "1" ] && perl -pi -e 's/^.*Mode.ine.*\n?//g' /etc/X11/$X_CONF # enable TV Out if -t option used [ "$TV" = "1" ] && perl -pi -e 's/^.*IgnoreDisplayDevices.*\n?//g' /etc/X11/$X_CONF # enable DynamicTwinView if -d option used [ "$DYN_TWINVIEW" = "1" ] && perl -pi -e 's/^(.*DynamicTwinView"\s*).*/\1"1"/g' /etc/X11/$X_CONF # disable DFP Native Resolution Check if -n option used [ "$NRC" = "0" ] && perl -pi -e 's/^([\s]*)#*([\s]*Option\s*"ModeValidation".*)/\1\2/g' /etc/X11/$X_CONF # Xorg 7.1 hack #X -version 2>&1|grep -q -e "X Window System Version 7.1" && perl -pi -e 's/^(.*RenderAccel"\s*).*/\1 "0"/' /etc/X11/$X_CONF fi rm -f /etc/X11/XvMCConfig if [ "$XVMC" = "1" -a "$LEGACY" = "0" -a -x /usr/lib/libXvMCNVIDIA_dynamic.so.1 ]; then echo libXvMCNVIDIA_dynamic.so.1 > /etc/X11/XvMCConfig else echo libXvMC.so.1 > /etc/X11/XvMCConfig fi [ "$HACK" = "1" ] && rm -rf /usr/lib/tls if [ "$ARCH" = "_64" -a "$EMUL" = "1" ]; then mkdir -p /emul/ia32-linux/usr/lib/tls/ rm -f /emul/ia32-linux/usr/lib/tls/libnvidia-tls.so.* rm -f /emul/ia32-linux/usr/lib/libGLcore.so.* rm -f /emul/ia32-linux/usr/lib/libGL.so.* rm -f /emul/ia32-linux/usr/lib/libnvidia-tls.so.* cp -v /usr/src/NVIDIA-Linux-x86-$VER-pkg$PKG/usr/lib/tls/libnvidia-tls.so.$DVER /emul/ia32-linux/usr/lib/tls/ cp -v /usr/src/NVIDIA-Linux-x86-$VER-pkg$PKG/usr/lib/libGLcore.so.$DVER /emul/ia32-linux/usr/lib/ cp -v /usr/src/NVIDIA-Linux-x86-$VER-pkg$PKG/usr/lib/libGL.so.$DVER /emul/ia32-linux/usr/lib/ cp -v /usr/src/NVIDIA-Linux-x86-$VER-pkg$PKG/usr/lib/tls/libnvidia-tls.so.$DVER /emul/ia32-linux/usr/lib/ ln -sf tls/libnvidia-tls.so.$DVER /emul/ia32-linux/usr/lib/libnvidia-tls.so.1 ln -sf libGLcore.so.$DVER /emul/ia32-linux/usr/lib/libGLcore.so ln -sf libGL.so.$DVER /emul/ia32-linux/usr/lib/libGL.so.1 ln -sf libGL.so.1 /emul/ia32-linux/usr/lib/libGL.so rm -rf /usr/src/NVIDIA-Linux-x86-$VER-pkg$PKG fi mkdir -p /etc/udev/rules.d rm -f /etc/udev/nvidia.rules /etc/udev/rules.d/nvidia.rules if [ "$UDEVHACK" = "1" ]; then cat < /etc/udev/nvidia.rules KERNEL=="nvidia", PROGRAM="/bin/sh -c '/bin/mknod /dev/nvidia0 -m 666 c 195 0 2>/dev/null;/bin/mknod /dev/nvidiactl -m 666 c 195 255 2>/dev/null'" EOF ln -s ../nvidia.rules /etc/udev/rules.d/nvidia.rules fi ldconfig sync if ! [ "$NO_X_KILL" = "1" ]; then if [ "$INSTALLED" = "yes" ]; then if [ -z "$DM" ]; then if [ -x /etc/init.d/kdm ]; then /etc/init.d/kdm start elif [ -x /etc/init.d/gdm ]; then /etc/init.d/gdm start elif [ -x /etc/init.d/xdm ]; then /etc/init.d/xdm start fi else [ -x /etc/init.d/$DM ] && /etc/init.d/$DM start fi else /etc/init.d/xsession restart fi fi