#!/bin/bash # ATI DRIVER INSTALLER # Check for root priveleges if [ $EUID -ne 0 ]; then echo "Please run the script as root" exit 1 fi # Print help help(){ echo "USAGE : $0 [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 them removeFiles(){ if [ -f $1 ]; then rm $1 fi } # Remove all deb and changes files in current directory removeOld(){ removeFiles *.deb removeFiles *.changes } # If number of arguments is less than 1, exit if [ $# -lt 1 ]; then help exit 1 fi # If 0, packages will only be built and not installed do_install=1 # If 0 drivers will be downloaded local_file=0 # If 0 XGL drivers will NOT be removed remove_xgl=0 for 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/\./-/'`;; esac done # If version number was not passed, exit if [ -z $version ]; then echo "Version number not passed" help exit 1 fi if [ $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.run fi if [ ! -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 1 fi if [ ! -x ati-driver-installer-"$version"-x86.x86_64.run ]; then chmod +x ati-driver-installer-"$version"-x86.x86_64.run fi echo "-----------------------------------" echo "Removing old package files" echo "-----------------------------------" removeOld if [ $remove_xgl -eq 1 ]; then echo "-----------------------------------" echo "Removing XGL" echo "-----------------------------------" sudo apt-get remove xserver-xgl fi echo "-----------------------------------" echo "Building new packages" echo "-----------------------------------" # Build packages sh ati-driver-installer-"$version"-x86.x86_64.run --buildpkg Ubuntu/hardy if [ $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 removeOld fi echo "-----------------------------------" echo "Operation completed successfully" echo "-----------------------------------" exit 0