All pastes #1235909 Raw Edit

Someone

public shellscript v1 · immutable
#1235909 ·published 2008-10-24 19:36 UTC
rendered paste body
#!/bin/bash# ATI DRIVER INSTALLER# Check for root privelegesif [ $EUID -ne 0 ]; then	echo "Please run the script as root"	exit 1fi# Print helphelp(){	echo "USAGE : $0 <OPTIONS> [VERSION]"	echo "Options:	-b | --build-only		Build packages only. Don't install	-h | --help				Show this	-l | --local			Don't download drivers and use local file in same directory as script	-xgl | --xgl			Remove XGL"}# If passed argument files exist, remove themremoveFiles(){	if [ -f $1 ]; then		rm $1	fi}# Remove all deb and changes files in current directoryremoveOld(){	removeFiles *.deb	removeFiles *.changes}# If number of arguments is less than 1, exitif [ $# -lt 1 ]; then	help	exit 1fi# If 0, packages will only be built and not installeddo_install=1# If 0 drivers will be downloadedlocal_file=0# If 0 XGL drivers will NOT be removedremove_xgl=0for argument in $*; do	case $argument in		"-b" | "--build-only" ) do_install=0;;		"-h" | "--help" ) help				exit 0;;		"-l" | "--local" ) local_file=1;;		"-xgl" | "--xgl" ) remove_xgl=1;;		* ) v=$argument			version=`echo "$v" | sed 's/\./-/'`;;	esacdone# If version number was not passed, exitif [ -z $version ]; then	echo "Version number not passed"	help	exit 1fiif [ $local_file -eq 0 ]; then	echo "-----------------------------------"	echo "Downloading driver from site"	echo "-----------------------------------"	wget http://www2.ati.com/drivers/linux/ati-driver-installer-8-10-x86.x86_64.runfiif [ ! -f ati-driver-installer-"$version"-x86.x86_64.run ]; then	echo "Driver version $v not available or file ati-driver-installer-$version-x86.x86_64.run does not exist"	exit 1fiif [ ! -x ati-driver-installer-"$version"-x86.x86_64.run ]; then	chmod +x ati-driver-installer-"$version"-x86.x86_64.runfiecho "-----------------------------------"echo "Removing old package files"echo "-----------------------------------"removeOldif [ $remove_xgl -eq 1 ]; then	echo "-----------------------------------"	echo "Removing XGL"	echo "-----------------------------------"	sudo apt-get remove xserver-xglfiecho "-----------------------------------"echo "Building new packages"echo "-----------------------------------"# Build packagessh ati-driver-installer-"$version"-x86.x86_64.run --buildpkg Ubuntu/hardyif [ $do_install -eq 1 ]; then	echo "-----------------------------------"	echo "Uninstalling old packages"	echo "-----------------------------------"	# Uninstall old packages	 apt-get remove xorg-driver-fglrx fglrx-amdcccle fglrx-kernel-source -y		echo "-----------------------------------"	echo "Installing new packages"	echo "-----------------------------------"	# Install new packages	 dpkg -i xorg-driver-fglrx_*.deb fglrx-kernel-source_*.deb fglrx-amdcccle_*.deb		echo "-----------------------------------"	echo "Removing temporary files"	echo "-----------------------------------"	# Remove deb files	 removeOldfiecho "-----------------------------------"echo "Operation completed successfully"echo "-----------------------------------"exit 0