#!/bin/bash # fglrx driver retriever and installer for Ubuntu Gutsy, by SheeEttin, based # off the procedure at http://wiki.cchtml.com/index.php/Ubuntu_Feisty_Installation_Guide # # Feel free to redistribute, derive, and include, but send me mail if you're # doing something neat with it # # Feedback welcome! Send mail to sheeettin@gmail.com version=1.14 # Version history available upon request. release="$(lsb_release -c | cut -f2)" case $@ in -r | --repository) # First off, make sure the restricted repo is available if grep -qE "^deb[[:space:]]+http://[a-z]{0,2}\.?archive\.ubuntu\.com/ubuntu/?[[:space:]]+${release}[[:space:]]+.*resrticted.*$" /etc/apt/sources.list then echo echo 'You need to enable the "restricted" repository in /etc/apt/sources.list!' exit 1 else echo echo "Installing from repositories." # Make sure we have updated package lists sudo apt-get update > /dev/null sudo apt-get install linux-restricted-modules-$(uname -r) restricted-manager if [ "$?" != "0" ]; then echo echo "Installing the linux-restricted-modules or restricted-manager package failed!" echo "Hopefully apt-get gave some errors from which you can work." exit 1 fi sudo apt-get install xorg-driver-fglrx if [ "$?" != "0" ]; then echo echo "Installing the xorg-driver-fglrx package failed!" echo "Hopefully apt-get gave some errors from which you can work." exit 1 fi # Module dependencies sudo depmod -a echo echo "Success!" fi ;; -m | --manual) # First off, make sure the universe & multiverse repos are available # if [ -z $(grep -E "^deb[[:space:]]+http://[a-z]{0,2}\.?archive\.ubuntu\.com/ubuntu/?[[:space:]]+${release}[[:space:]]+.*universe.*$" /etc/apt/sources.list) ] if grep -qE "^deb[[:space:]]+http://[a-z]{0,2}\.?archive\.ubuntu\.com/ubuntu/?[[:space:]]+${release}[[:space:]]+.*universe.*$" /etc/apt/sources.list then if grep -qE "^deb[[:space:]]+http://[a-z]{0,2}\.?archive\.ubuntu\.com/ubuntu/?[[:space:]]+${release}[[:space:]]+.*multiverse.*$" /etc/apt/sources.list then # Install necessary tools sudo apt-get update > /dev/null sudo apt-get install build-essential debconf debhelper dh-make dkms fakeroot libstdc++5 linux-headers-$(uname -r) || exit 1 # So nothing interferes with us tdir="$(mktemp -dt fglrx-install.XXXXXXXXXX)" cd $tdir # -nc is used so that it's not downloaded multiple times. This may be bad if the MD5 check fails. echo echo "Getting the installer..." wget -nc --no-check-certificate https://www2.ati.com/drivers/linux/ati-driver-installer-8-6-x86.x86_64.run echo echo "Running installer..." sudo sh ati-driver-installer-8-6-x86.x86_64.run --buildpkg || exit 1 echo echo "If you've previously installed the fglrx driver from the repository," echo "you need to blacklist the old module." read -p "Do this now? (y/n) [y] " blacklist case $blacklist in n) echo echo "Not blacklisting." ;; *) # If it's not a no, it's a yes # Blacklist the module, but first make sure it isn't in there already if [ -z $(grep '^DISABLED_MODULES=".*\bfglrx\b.*"$' /etc/default/linux-restricted-modules-common) ] then sudo sed -i 's/^DISABLED_MODULES="\(.*\)"$/DISABLED_MODULES="\1 fglrx"/' \ /etc/default/linux-restricted-modules-common else echo echo "It's already in there. No action taken." fi ;; esac # No building any more, it's handled automatically by DKMS # Package installation is too, but it seems to be broken sudo dpkg -i ./*.deb # Skip removal for ease of debugging (it's in /tmp anyway) #cd .. #rm -rf $tdir echo echo "Success!" echo "Please note that since you did this manually, you'll need to do it again" echo "whenever you upgrade your kernel. (Basically, if you boot one day and you have" echo "no video, just re-execute \"$0 -m\".)" else echo 'You need to enable the "multiverse" repository in /etc/apt/sources.list!' exit 1 fi else echo 'You need to enable the "universe" repository in /etc/apt/sources.list!' exit 1 fi ;; -v | --version) echo $version exit 0 ;; *) echo "Usage: $0 [OPTION]" echo "Install the proprietary fglrx drivers from ATI." echo # echo "Options:" echo " -h, --help Display this message" echo " -v, --version Display version number" echo " -r, --repository Download from repositories" echo " -m, --manual Get manually (i.e. from ATI)" echo echo "This script may be run as root or not, your choice. If you choose not to run it" echo "as root, you may be prompted for your password one or more times for sudo." exit 0 ;; esac echo echo "You probably need to tweak your xorg.conf now. The best way to do this" echo "is to reconfigure, but you may like your current config. If you want to" echo "reconfigure, do \"sudo dpkg-reconfigure xserver-xorg\" and select the fglrx" echo "driver. Else, just edit /etc/X11/xorg.conf as root and change the driver line." echo "(Don't forget to reboot if upgrading or installing for the first time.)" echo # This does not help with direct rendering. Should this be implemented in this script? # Also being considered: automatic xorg.conf configuration to change the driver to fglrx. # Also: How about uninstallation?