All pastes #436093 Raw Edit

zeroflag

public shellscript v1 · immutable
#436093 ·published 2007-04-12 10:29 UTC
rendered paste body
#!/bin/bash################################################################## # Simple script to install NVIDIA's driver packages into ubuntu (Tested with feisty x64).# Copyright (C) 2007  Thomas "zeroflag" Kraemer## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.# # This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.# ################################################################## I KNOW this script looks like crap but this is the first bash script I've done, ever.# plus, I only used linux for a couple of days so if anything goes wrong, feel free to complain, but it's still on you. ;)wm="gdm"if [[ "$1" = "-k" || "$1" = "-kde" || "$1" = "--kde" ]]; then	wm="kde"	shift;fiplatform=`uname -m`lib="lib"if [ "$platform" = "x86_64" ]; then	lib="lib64"	echo "Working with x86_64 Platform and Window Manager $wm."else	echo "Working with x86 Platform and Window Manager $wm."fiif [ "$1" = "" ]; then	echo "Usage:"	echo "nvidia_install [-k] <nvidia_driver_package.run> [autoconfig]"	echo "nvidia_install download"	echo ""	echo "	-k:	Works with KDE instead of Gnome."	echo "	<nvidia_driver_package.run>:"	echo "		A nvidia driver package for linux."	echo "		e.g. NVIDIA-Linux-x86_64-1.0-9755-pkg2.run"	echo "	autoconfig:	"	echo "		Will run nvidia-xconfig after installation."	echo "		Otherwise you'll have to edit /etc/X11/xorg.conf yourself."	echo ""	echo "	download:"	echo "		Will run w3m on http://www.nvidia.com/object/unix.html so you can download a kernel."	echo ""	echo "WARNING:   This will remove all restricted modules!"	echo "IMPORTANT: DO NOT RUN THIS SCRIPT FROM A GNOME/KDE TERMINAL!!!"	exit 0fiexit 0#set -xset -eif [ "$1" = "download" ]; then	sudo apt-get -y install w3m	w3m http://www.nvidia.com/object/unix.htmlelse	file=$1	folder=${file%.run}	echo "Will extract $file to $folder"	echo "Stopping $wm..."	sudo /etc/init.d/$wm stop	echo "Retrieving required packages..."	sudo apt-get -y install linux-headers-`uname -r` build-essential gcc gcc-3.4 xserver-xorg-dev	echo "Puring restricted modules and old nvidia packages..."	sudo apt-get -y --purge remove linux-restricted-modules-`uname -r` linux-restricted-modules-common nvidia-glx nvidia-settings nvidia-kernel-common	sudo rm -f /etc/init.d/nvidia-*	echo "Removing old driver folder..."	sudo rm -f -r $folder	echo "Extracting nvidia driver package..."	bash $file --extract-only	echo "Entering extracted folder..."	cd $folder	echo "Running the installer..."	sudo ./nvidia-installer -n -s -a --no-questions --x-prefix=/usr/$lib/xorg/ --kernel-source-path=/usr/src/linux-headers-`uname -r`	echo "Installation finished."	if [ $2 = autoconfig ]; then		echo "Automated configuration..."				echo "Preparing configuration..."		sudo apt-get -y install nvidia-xconfig				echo "Running configuration..."		sudo nvidia-xconfig	fi	echo "Restarting $wm..."	sudo /etc/init.d/$wm restart	echo "Done."fi