#!/bin/bash ######################################################################## #### Script Name: system graphics installer: sgfxi #### Use for Debian Sid, Testing, and sidux graphic driver install. #### Only supports true Debian based distros. #### version: 4.0.11 #### Date: November 19 2008 ######################################################################## #### Copyright (C) Harald Hope 2007-2008 #### Code contributions copyright: Latino 2008 #### Contributors: ati card driver and xorg configuration in general: damentz and d2kx #### 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. #### #### Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt ######################################################################## #### Script URL: http://smxi.org/sg/sgfxi #### Script SVN: http://code.google.com/p/sgfxi #### Script Documentation: http://smxi.org/docs/ #### Script Home page: http://techpatterns.com/forums/about933.html ######################################################################## #### DEFINE: #### TRUE: -eq 0; == 'true'; function return 0 #### FALSE: -gt 0; == ''; function return > 0 ######################################################################## #### CONVENTIONS: #### Indentation: TABS #### Do not use `....`, those are totally non-reabable, use $(....) #### Do not use one liner flow controls. The ONLY time you should use ; is in #### this single case: if [ condition ];then (ie, never: [ condition ] && statement) #### #### All new code/methods must be in a function. #### For all boolean tests, use 'true' / 'false'. Do NOT use 0 or 1 unless #### it's a function return. Avoid complicated tests in the if condition itself. #### #### VARIABLE/FUNCTION NAMING: #### All variables should explain what they are, except counters like i, j #### All variables MUST be initialized / declared explicitly ####, globals UPPER CASE, at top of script, SOME_VARIABLE='' (words separated by _ ). #### Locals always: local someVariable= (lower case, all except first word started upper case) #### and at the top of the function. ie: testTrunkData #### #### Booleans should start with b_ or B_ and state clearly what is being tested #### Arrays should start with a_ or A_ #### All functions should follow standard naming, ie, verb adjective noun, get_cpu_data ######################################################################## #### TESTING FLAGS #### sgfxi supports advanced testing triggers to do various things, using -! #### -! 1 - triggers default B_TESTING_1='true' to trigger some test or other #### -! 2 - triggers default B_TESTING_2='true' to trigger some test or other #### -! 3 - triggers default B_SKIP_FUNCTION='true' to turn off some functions #### -! 4 - triggers B_TESTING_1='true' and B_TESTING_2='true' #### -! 5 - triggers B_TESTING_1='true' and B_SKIP_FUNCTION='true' #### -! 10 - triggers an update from the primary dev download server #### -! 11 - triggers an update from svn branch one - if present, of course #### -! 12 - triggers an update from svn branch two - if present, of course #### -! - Triggers an update from whatever server you list. #### -! 20 - uses patch from svn branch one server (must be in branch/one/patches) #### -! 21 - uses patch from svn branch two server (must be in branch/two/patches) ######################################################################## #### VARIABLES ######################################################################## APT_TYPE='apt-get' CARD='' # card type: fglrx or nvidia AUTORUN='' DISPLAY_DEVICES='' SM_INSTALL='' # utilities for smxi EXPERIMENTAL='' EXTRA_EXPERIMENTAL='' FORCE_UPDATE='' NATIVE_DRIVER='' NATIVE_OVERRIDE='' # this is the actual pattern that will be used to search for this stuff in script NATIVE_OVERRIDE_SUPPORTED='ati|i128|i740|i810|i810-modesetting|intel|mga|neomagic|nv|openchrome|radeon|radeonhd|sis|tdfx|vesa|via|vga|voodoo' NO_XVMC='' PACKAGE_MANAGER='' PRINT_VER='' # utilities for smxi REMOVE_MODELINES='' # options: 0 - monochrome; 1 default; more coming? SCRIPT_COLORS=1 SKIP_AUTOSTART='' SKIP_CONFIG='' SKIP_CONNECT='' SKIP_RESTART='' SKIP_WGET='' SKIP_X_QUESTION='' SKIP_X_TEST='' START_OPTIONS_PRINT='' # for output to user of what options they used START_OPTIONS='' SYSTEM_BASE='' TRIPLE_BUFFER='' TWINVIEW='' USE_DEBIAN_DRIVER='' WITHOUT_RECOMMENDS='' # triggers above automatically if required DEBIAN_FLAG='' ## debugger/testing booleans B_SKIP_FUNCTION='' B_TESTING_1='' B_TESTING_2='' ARCH='' # kernel variables strings are now evaluated in kernel_string_info(). INSTALL_TO_KERNEL='' KERNEL_VERSION='' # full kernel name KERNEL_BASE='' # like: 2.6 # note the extra cut -d '-' -f 1 test is to dump the doubled 2.6.24 in new kernel strings. KERNEL_THREE='' # like: 2.6.19 KERNEL_THIRD='' # like: 19, for math use IS_SIDUX_KERNEL='' IS_XEN='' # check for 64 bit first if [ -n "$( uname -m | grep -o 'x86_64' )" ];then BITS="64" else BITS="32" fi # this handles the 1.x syntax used by xorg version in experimental # it also handles the totally pointless change in ID text they did with 1.4 X_VERSION=$( X -version 2>&1 | grep 'X Window System' | egrep -o '(7|1)\.[1-6]' ) if [ -z "$X_VERSION" ];then X_VERSION=$( X -version 2>&1 | grep 'X.Org X Server' | egrep -o '(7|1)\.[1-6]' ) fi CC='' GL='' # specific card types FGLRX='fglrx' INTEL='intel' NEOMAGIC='neomagic' NVIDIA='nvidia' TDFX='tdfx' DISPLAY_MANAGER=$( cat /etc/X11/default-display-manager 2>/dev/null ) DISPLAY_MANAGER=$( basename $DISPLAY_MANAGER 2>/dev/null ) # Position matters: 1-latest; 2-middle; 3-older; 4-oldest VERSIONS='' OTHER_VERSIONS='' # other stuff: nothing now NV_VERSIONS='177.82:173.14.12:96.43.07:71.86.06' NV_DEFAULT='177.82' NV_LEGACY_1=$( echo $NV_VERSIONS | cut -d ':' -f 4 ) NV_LEGACY_2=$( echo $NV_VERSIONS | cut -d ':' -f 3 ) # until 177.xx goes stable, then change to cut -d 2. This will change how smxi # graphics data is handled too, instead of a one previous, there will be 3 legacy levels # plus current driver. Given how many 5xxx cards are, that's worth doing. NV_LEGACY_3=$( echo $NV_VERSIONS | cut -d ':' -f 2 ) # latest quad: http://www.nvidia.com/object/linux_display_archive.html NV_QUAD=$NV_DEFAULT # no more individual quad drivers NV_TESTING='180.08:180.06:173.14.15:96.43.09:71.86.07' NV_OTHERS='177.80:169.12:100.14.19:96.43.05:71.86.04' # debian sid legacies: NV_DEBIAN_LEGACY_1='71xx' NV_DEBIAN_LEGACY_2='96xx' # default download site for nvidia NVIDIA_DOWNLOAD_SITE='http://us.download.nvidia.com' # other options: nothing now # IMPORTANT: on function set_download_info the actual path file name is set: FG_VERSIONS='8-11:8-10:8-9' FG_DEFAULT='8-11' FG_LEGACY='' # no legacy for ati + xorg >= 7.1 FG_TESTING='' FG_OTHERS='8-8:8-7:8-6:8-5:8-4' DRIVER_LEGACY='' DRIVER_INSTALL='' DRIVER_DEFAULT='' DRIVER_OVERRIDE='' DRIVER_QUAD='' DRIVER_TESTING='' # 0 - unsupported completely by any non-free driver # 1 - nvidia oldest card versions supported # 2 - nvidia midrange legacy card versions supported # 3 - nvidia 5xxx cards only # 100 - fully supported with latest driver LEGACY_LEVEL='' DRIVER_FILE='' USE_XVMC='' ATI_MOD_CONFIG='' UPDATED='' XORG_BACKED_UP='' # here we're cutting out both card type and version number for cases with > 1 card CARD_COUNT=$( lspci -n | grep -c '0300' ) #CARD_DATA=$( lspci -n | grep 0300 | cut -d ':' -f 3-4 | cut -d ' ' -f2 ) CARD_DATA=$( lspci -n | grep '0300' | egrep -io '[a-f0-9]{4}:[a-f0-9]{4}' ) CARD_NUMBER='' CARD_BRAND='' # this is reset for multiple gfx cards in select_card() # " around CARD_DATA is mandatory for avoiding new grep issue BUS_ID=$( lspci -n | grep "$CARD_DATA" | egrep -io '^[0-9]{1,2}:[0-9a-z]{1,2}(\.|:)[0-9]' | sed 's/\./:/') COMPOSITE='' # default false # RENDER_ACCEL='true' # default use, true # system paths EAS='/etc/apt/sources.list' EXXC='/etc/X11/xorg.conf' EDV='/etc/debian_version' SCRIPT_HOME='/usr/local/bin' INSTALL_WORKING_DIR='/usr/src/' INSTALL_DIRECTORY='' FG_WORKING_DIR='fglrx-install' # file and patch urls PATCH_DOWNLOAD='http://smxi.org/sg/' SCRIPT_DOWNLOAD='http://smxi.org/sg/' SCRIPT_DOWNLOAD_DEV='http://techpatterns.com/downloads/distro/' SCRIPT_DOWNLOAD_BRANCH_1='http://sgfxi.googlecode.com/svn/branches/one/' SCRIPT_DOWNLOAD_BRANCH_2='http://sgfxi.googlecode.com/svn/branches/two/' DEBIAN_FGLRX='debian-fglrx' DEBIAN_NVIDIA='debian-nvidia' LOG_FILE_DIR="/var/log/sgfxi/" LOG_FILE='sgfxi.log' LOGGING_STARTED='' LOGPS='log_function_data ps $FUNCNAME "$( echo $@ )"' LOGPE='log_function_data pe $FUNCNAME' LOGUS='log_function_data us $FUNCNAME "$( echo $@ )"' LOGUE='log_function_data ue $FUNCNAME' SCRIPT_NAME='sgfxi' SCRIPT_ROTATE="/etc/logrotate.d/$SCRIPT_NAME" SM_VALUES='/usr/local/bin/sgfxi-values' EXPERIMENTAL_XORG_ATI='xserver-xorg-video-ati_6.6.193-1' EXPERIMENTAL_LIBDRM2='libdrm2_2.4.0~git20070625-1' EXPERIMENTAL_LIBDRM_DEV='libdrm-dev_2.4.0~git20070625-1' # this handles two cases: 1 where user logged in directly as 'root', and # 2, where user su to root. LOGIN_PID=$( ps | grep ' login' ) if [ "$LOGIN_PID" == '' ];then LOGIN_PID=$( ps | grep ' su' ) fi LOGIN_PID=$( echo $LOGIN_PID | grep -o "[0-9]*" ) # allow user set globals to override script globals if [ -f $SM_VALUES ];then source $SM_VALUES fi ######################################################################## #### FUNCTIONS ######################################################################## ######################################################################## #### driver+kernel support tests, and patch handlers: #### ------------------------------------------------------------------- ## these are first to make it easy to update each new driver release support data # args: $1- test type driver_support_tests() { eval $LOGUS # test for binary only tests here case $1 in supported-driver) case $CARD in $FGLRX) case $KERNEL_THIRD in # handle no sidux kernel support first 25|26|27) # for testing/debugging set this re: # http://techpatterns.com/docs/sgfxi-set-test-data.htm if [ -n "$IS_SIDUX_KERNEL" ];then error_handler 229 #fglrx is working on Debian kernels, so users who want up to date #system will need to use debian kernels + fglrx else case $KERNEL_THIRD in 26) case $DRIVER_DEFAULT in 8-4|8-5) error_handler 234 26 ;; esac ;; 27) case $DRIVER_DEFAULT in 8-4|8-5|8-6|8-7|8-8|8-9) error_handler 234 27 ;; *) : # not yet, let's see: error_handler 234 27 ;; esac ;; esac fi ;; esac ;; $NVIDIA) if [ "$DRIVER_DEFAULT" == "$DEBIAN_NVIDIA" -a "$SYSTEM_BASE" == 'testing' ];then print_information_continue 'standard' "Your system appears to be Debian Testing based.\nThe $DEBIAN_NVIDIA driver cannot build on Debian Testing because of a missing package.\nIf your system is Sid based, continue, otherwise exit now." else ## test for >= xorg 1.5 support case $X_VERSION in 1.[5-9]|2.[0-9]|7.[6-9]) case $DRIVER_DEFAULT in 180.08|180.06|177.82|177.80|173.14.15|96.43.09|71.86.07) : ## support should be working, see feedback ;; *) error_handler 226 ;; esac ;; esac # set alternate download location if required, nvidia is using this # now for all beta driver releases. Stable drivers are using http case $DRIVER_DEFAULT in 180.08|173.14.15|96.43.09|71.86.07) NVIDIA_DOWNLOAD_SITE='ftp://download.nvidia.com' ;; esac # handle change to legacy 5xxx level cards case $DRIVER_DEFAULT in 180.08|180.06|177.82|177.80) if [ "$LEGACY_LEVEL" -eq 3 ];then error_handler 227 fi ;; esac # basic version handling and support tests, unless otherwise reported, # $DEBIAN_NVIDIA will be supported by default case $KERNEL_THIRD in 24) # going to try just 2.6.24 links, see if any issues appear # this doesn't work on debian kernels if [ -n "$IS_SIDUX_KERNEL" ];then misc_fixes nvidia-24-link # this might always be needed, all cases? fi ;; 26) case $DRIVER_DEFAULT in 180.08|180.06|177.82|177.80|173.14.15|173.14.12|100.14.19|96.43.09|96.43.07|71.86.07|71.86.06|$DEBIAN_NVIDIA) : # do nothing ;; *) error_handler 234 $KERNEL_THIRD ;; esac ;; 27) case $DRIVER_DEFAULT in 180.08|180.06|177.82|177.80|173.14.15|173.14.12|100.14.19|96.43.09|96.43.07|71.86.07|71.86.06|$DEBIAN_NVIDIA) : # do nothing ;; *) if [ "$B_TESTING_1" != 'true' ];then error_handler 234 $KERNEL_THIRD fi ;; esac ;; 28) case $DRIVER_DEFAULT in 180.08|180.06|177.82|177.80|173.14.15|96.43.09|71.86.07) : # do nothing ;; *) if [ "$B_TESTING_1" != 'true' ];then error_handler 234 $KERNEL_THIRD fi ;; esac ;; esac fi ;; esac ;; nvidia-supported-driver) : ;; ati-supported-driver) : ;; esac eval $LOGUE } # these patch calls used to be in lib files but this is cleaner/simpler long term run_patches() { eval $LOGPS local patchFile='' case $CARD in $NVIDIA) case $KERNEL_THIRD in 25) apply_module_patch pre case $DRIVER_DEFAULT in 171.06|169.12) patchFile='NVIDIA_kernel-169.12-2286310.diff' apply_patch_file $patchFile ;; # patch url: http://www.nvnews.net/vbulletin/showthread.php?t=112452 100.14.19|100.14.23) # patch source url: # http://www.nvnews.net/vbulletin/showthread.php?t=112452&highlight=2.6.26 # patch author: NiLuJe if [ "$BITS" == '32' ];then patchFile='NVIDIA-x86-100.14.19-kernel-2.6.25-compat.diff' else patchFile='NVIDIA-x86_64-100.14.19-kernel-2.6.25-compat.diff' fi apply_patch_file $patchFile ;; 96.43.05) patchFile='NVIDIA_kernel-96.43.05-2290218.diff' apply_patch_file $patchFile ;; 71.86.04) patchFile='NVIDIA_kernel-71.86.04-2305230.diff' apply_patch_file $patchFile ;; esac ;; 26) apply_module_patch pre case $DRIVER_DEFAULT in 173.14.05) patchFile='NVIDIA_kernel-173.14.05-2419292.diff' apply_patch_file $patchFile ;; 100.14.19) # patch source url: # http://www.nvnews.net/vbulletin/showthread.php?t=112452&highlight=2.6.26 # patch author: NiLuJe, MamiyaOtaru, zander (from nvidia) # patchFile='NVIDIA-100.14.19-kernel-2.6.25+26-compat.diff' patchFile='NVIDIA-100.14.19-for-2.6.26.patch' apply_patch_file $patchFile ;; esac ;; 27) apply_module_patch pre case $DRIVER_DEFAULT in 177.13) # patch author: zander, nvidia; patch src: # http://www.nvnews.net/vbulletin/showthread.php?t=117209 # patch url: # http://www.nvnews.net/vbulletin/attachment.php?attachmentid=32559&d=1218212371 patchFile='NVIDIA_kernel-177.13-2627763.diff' apply_patch_file $patchFile ;; 173.14.12|96.43.07) # patch file source: # http://www.nvnews.net/vbulletin/showthread.php?t=120884 patchFile='NVIDIA-173.14.12-2.6.27.patch' apply_patch_file $patchFile ;; 71.86.06) # patch file source: # http://www.nvnews.net/vbulletin/showthread.php?t=120971 patchFile='NVIDIA-71.86.06-2.6.27.patch' apply_patch_file $patchFile ;; # patch url: http://www.nvnews.net/vbulletin/showthread.php?t=112452 100.14.19|100.14.23) patchFile='NVIDIA-100.14.19-kernel-2.6.27-compat.patch' apply_patch_file $patchFile ;; esac ;; 28) case $DRIVER_DEFAULT in 177.80) # post 21:http://www.nvnews.net/vbulletin/showthread.php?t=121790 patchFile='NVIDIA_2.6.28-177.80-2990799.diff' apply_patch_file $patchFile ;; 177.82) # post 44: http://www.nvnews.net/vbulletin/showthread.php?t=121790&page=2 patchFile='NVIDIA_2.6.28-177.82.diff' apply_patch_file $patchFile ;; esac ;; esac ;; $FGLRX) case $KERNEL_THIRD in 25|26) case $DRIVER_DEFAULT in # 8-4|8-5) # # debian kernls work normally, no patch required # # note: due to concerns raised, this patch is not going to be used # if [ -n "$IS_SIDUX_KERNEL" ] # then # # pre patch link required, just to keep the information for future reference: # ln -s arch/x86/usr/X11R6/lib/libfglrx_gamma.so.1.0 arch/x86/usr/X11R6/lib/libfglrx_gamma.so.1 # ln -s arch/x86_64/usr/X11R6/lib64/libfglrx_gamma.so.1.0 arch/x86_64/usr/X11R6/lib64/libfglrx_gamma.so.1 # patchFile='' # #apply_patch_file $patchFile # fi # ;; 8-6) patchFile='0001-catalyst-8.6-linux-2.6.26.patch' apply_patch_file $patchFile patchFile='0002-catalyst-8.6-linux-2.6.26.patch' apply_patch_file $patchFile patchFile='0003-catalyst-8.6-linux-2.6.26.patch' apply_patch_file $patchFile ;; 8-7) # patch url: http://bugs.gentoo.org/attachment.cgi?id=161335 # found at: http://bugs.gentoo.org/show_bug.cgi?id=232609 patchFile='FGLRX-8.7-2.6.26.patch' # this one is crap, bad hunks #patchFile='FGLRX-0004-Linux-2.6.26.x-kernels-support.patch' apply_patch_file $patchFile ;; esac ;; esac ;; esac # this is for dev testing of patches or fixes if [ "$B_TESTING_1" == 'true' ];then : # doing nothing for now fi eval $LOGPE } ######################################################################## #### primary startup - colors, test data, #### ------------------------------------------------------------------- # set global color variables # options: 0 - turns off all colors; 1 - defaults set_script_colors() { # set colors case $SCRIPT_COLORS in 0) W='' # red: Warning message E='' # yellow: script Error S='' # green: Standard message Q='' # CYAN: Questions M='' # CYAN: Message B='' # BLUE: Message C='' # MAGENTA: Command or Path N='' # default system console color: Normal :: make last in colors ;; 1) W="" # red: Warning message E="" # yellow: script Error S="" # green: Standard message Q="" # CYAN: Questions M="" # CYAN: Message B="" # BLUE: Message C="" # MAGENTA: Command or Path N="" # default system console color: Normal :: make last in colors ;; 2) W="" # red: Warning message E="" # yellow: script Error S="" # Standard message Q="" # CYAN: Questions M="" # CYAN: Message B="" # BLUE: Message C="" # MAGENTA: Command or Path N="" # default system console color: Normal :: make last in colors ;; 3) W="" # red: Warning message E="" # yellow: script Error S="" # Standard message Q="" # CYAN: Questions M="" # CYAN: Message B="" # BLUE: Message C="" # MAGENTA: Command or Path N="" # default system console color: Normal :: make last in colors ;; esac CALLER_DEF=${S} # will switch default output color to the calling script's S=${B} # this is slightly tricky, making standard blue AFTER the caller def is set. LINE='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -' } # only for debugging purposes set_test_data() { local username='' if [ "$B_TESTING_1" == 'true' ];then # set testing directories etc ## NOTE: it's important to start all comments in here at first character for cleanup updater # # this is required for testing to make sure we always are starting with true # # latest script versions # # note: devs: double check this output to make sure it's your user name # username=$( getent passwd 1000|cut -d \: -f1 ) # SCRIPT_HOME="/home/$username/bin/scripts/sgfxi/dev/" # INSTALL_WORKING_DIR="/home/$username/bin/scripts/sgfxi/dev/" # LOG_FILE_DIR="/home/$username/bin/scripts/sgfxi/dev/" # cd $SCRIPT_HOME # rm -f sgfxi.log # # sgfxi doesn't support any legacy ATI stuff # CARD_DATA=1002:7280 # fake ati # CARD_DATA=10de:0020 # fake nvidia oldest legacy (7x.xx.xx drivers) # CARD_DATA=10de:0280 # fake nvidia mid legacy (9x.xx.xx drivers) # CARD_DATA=10de:0322 # fake nvidia 5xxx legacy (173.xx.xx drivers) # CARD_DATA=10de:0422 # fake nvidia current card (GS 8400) # FG_DEFAULT='8-5' # NV_DEFAULT='177.80' # # set system bits to test 32/64 specific behaviors # BITS=64 # # if you want to test for/without sidux kernels, set to null '' or 'true' # IS_SIDUX_KERNEL='' # # to test patches/error handling for a specific kernel major version, # # ie: 2.6.25 here # KERNEL_THIRD=28 # # values: '' or 'true' # IS_XEN='' # # check for specific system base tests, can be: # # 'sid' 'testing' 'stable' 'etch' # SYSTEM_BASE='testing' # leave this at first character or errors in updater tools will occur : fi } ######################################################################## #### Error handling and detections #### ------------------------------------------------------------------- error_handler() { local errorCode=$1 # error number local errorExtra=$2 # this is secondary info, like failed package name local errorData='' local ErrorMessage='' case $errorCode in # general system checks 254) errorData="No supported $CARD card found!" ;; 253) errorData="No supported $CARD card found!\nYou can use this script to install the native Xorg drivers: $SCRIPT_NAME -n" ;; 252) errorData="This does not appear to be a Debian apt based system!" ;; 251) errorData="You must be logged in as root to run this script." ;; 250) errorData="You must be out of X/KDE to run this graphics installer." ;; 249) errorData="Your system does not have the correct version of X, $EXXC" ;; 248) errorData="Sorry, Ubuntu isn't supported by this script" ;; 247) errorData="You can't use the composite option with this driver: $DRIVER_DEFAULT" ;; 246) errorData="The driver: $DRIVER_DEFAULT is not currently supported for kernel version 2.6.$KERNEL_THIRD" ;; 245) errorData="The $CARD installer exited with the error: $errorExtra" ;; 244) errorData="Xorg does not appear to be installed." ;; 243) errorData="Your kernel type $KERNEL_BASE is not supported for these drivers." ;; 242) errorData="This script requires X.org 7.1 or greater to be installed on your system." ;; 241) errorData="This script does not support the $CARD driver: $errorExtra\nPlease make sure to enter a supported driver when using the -o option." ;; 240) errorData="This script does not support the $CARD driver: $errorExtra" ;; 239) errorData="This script does not support installing $CARD drivers in livemode." ;; 238) errorData="There does not appear to be a live connection, or $SCRIPT_NAME script server is down.\nIf you are sure you have a connection, restart script with -Z option to cancel connection test." ;; 237) errorData="The native xorg driver you selected: $errorExtra is not supported." ;; 236) errorData="An ATI $CARD error makes them not support your Xorg version $errorExtra\n If you are using less than R500 type card, you can install native radeon drivers with this script.\nUse this syntax to install those and reconfigure xorg.conf: $SCRIPT_NAME -N radeon" ;; 235) errorData="The driver $DRIVER_DEFAULT requires the 2.6.$errorExtra kernel to run.\nYou are running the $KERNEL_THREE kernel. Please update your kernel now." ;; 234) errorData="The driver $DRIVER_DEFAULT does not support the 2.6.$errorExtra kernel.\nYou are running the $KERNEL_VERSION kernel. Unable to install your $DRIVER_DEFAULT driver." ;; 233) errorData="Creating the fix: $errorExtra for your $DRIVER_DEFAULT and kernel $KERNEL_VERSION failed." ;; 232) errorData="The kernel for -K option: $errorExtra does not appear to be installed in your system." ;; 231) errorData="The file: $errorExtra appears to be corrupted. Please try to update again." ;; 230) errorData="Could not detect gcc version: $errorExtra, or it is not installed.\nPlease let the script maintainer know, this may be a bug in the script." ;; 229) errorData="The driver: $DRIVER_DEFAULT does not work on sidux kernels.\nYou are trying to install it to this kernel: $KERNEL_VERSION\nCurrently $FGLRX only works on new Debian kernels." ;; 228) errorData="The option you selected: $errorExtra is not supported." ;; 227) errorData="The newest $CARD drivers ( >= 177.167 ) no longer support your $CARD GeForce 5xxx card.\nYou must use the $NV_LEGACY_3 driver or lower.\nThat is the default driver when you run this script." ;; 226) errorData="The driver you selected: $DRIVER_DEFAULT does not support your current Xorg version: $X_VERSION\nIf this is wrong, please let the script maintainer know." ;; # specific install issues 200) errorData="The package: $errorExtra failed to install, please check apt for any problems." ;; 199) # replaced by 231 errorData="The file: $errorExtra failed to download - wget reports success." ;; 198) errorData="The url/file: $errorExtra\nfailed to download - wget error." ;; 197) errorData="The graphics driver installer: $errorExtra failed to download - wget error." ;; 196) errorData="The driver package: $errorExtra failed to extract and has been deleted." ;; 195) errorData="dkpg -i failed for package: $errorExtra" ;; 194) errorData="m-a build failed for package: $errorExtra" ;; 193) errorData="m-a install failed for package: $errorExtra" ;; 192) errorData="The $CARD driver uninstaller exited with this error: $errorExtra" ;; 191) errorData="This script cannot proceed if you leave $errorExtra installed." ;; 190) errorData="Removing package $errorExtra failed." ;; 189) errorData="Downloading the experimental driver $errorExtra failed." ;; 188) errorData="The experimental driver $errorExtra package is empty." ;; 187) errorData="The experimental driver package $errorExtra is not available currently, sorry." ;; 186) errorData="The package $errorExtra was not created. Cannot continue with install." ;; 185) errorData="m-a prepare failed for package: $errorExtra" ;; 184) errorData="m-a update failed for package: $errorExtra" ;; 183) errorData="depmod -a failed for package: $errorExtra" ;; 182) errorData="m-a clean failed for package: $errorExtra" ;; 181) errorData="Patch file: $errorExtra failed to download." ;; 180) errorData="wget error: Patch file: $errorExtra failed to download." ;; 179) errorData="Patching error: file: $errorExtra failed." ;; 178) errorData="Unsupported testing option argument: -! $errorExtra" ;; 100) errorData="The function: $errorExtra exited through user action." ;; *) errorData="Unexpected Error !" ;; esac ErrorMessage="ERROR: ($errorCode) $errorData" echo -e ${E}$ErrorMessage${N} if [ -f $LOG_FILE -a "$LOGGING_STARTED" == 'true' ];then log_function_data "$ErrorMessage" echo echo "${S}Log file is located here: $LOG_FILE" fi echo "${M}Exiting script now.${N}" exit $errorCode } # this only runs if card count > 1 select_card() { #cardData=$(echo "00:0d.0 VGA compatible controller [0300]: nVidia Corporation GeForce 6100 nForce 405 [10de:03d1] (rev a2) #02:00.0 VGA compatible controller [0300]: nVidia Corporation G71 [GeForce 7300 G S] [10de:01df] (rev a1)" | egrep 'VGA' | cut -d ':' -f 3-4 | cut -d ' ' -f 2-50 | tr ' ' '-' ) #tester="00:0d.0 0300: 10de:03d1 (rev a2) #02:00.0 0300: 10de:01df (rev a1) " local cardData=$( lspci -nn | grep 'VGA' | cut -d ':' -f 3-4 | cut -d ' ' -f 2-50 | tr ' ' '-' ) local cards='' card='' singleCardId='' local options='' opt='' found='' local timeStampXorg=$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S ) echo ${M}$LINE echo "${S}The script detected more than one video card in your system:" echo "${C}$cardData" echo echo "${M}If you want to preserve your current xorg.conf, for example if you use dual" echo "card setup, and your system is working fine with the driver you are installing," echo "please restart sgfxi with extra -C option and it will not change xorg.conf." echo echo "${S}sgfxi will adjust your xorg.conf busID. For typical, single monitor/dual card setups, this is desirable," echo "but for rare cases of dual card, dual monitor setups, you may want to start with -C " echo echo "If you proceed without -C, a copy of your current xorg.conf will be made here: ${C}$timeStampXorg" echo echo "${S}Please select which card you want to install a driver for now to proceed:" echo ${M}$LINE${N} options="$cardData exit" select opt in $options do for card in $options do if [ "$opt" == "$card" ];then if [ "$card" == 'exit' ];then echo "${S}Exiting script now.${N}" exit 0 else singleCardId=$( echo $card | egrep -o -i '[a-z0-9]{4}:[a-z0-9]{4}' ) echo "${S}You have elected to install drivers for this video card:" echo "${C}$card${N}" # override the global values and handle this explicitly CARD_DATA=$singleCardId if [ "$SKIP_CONFIG" != 'true' ];then if [ ! -e $timeStampXorg ];then cp $EXXC $timeStampXorg fi log_function_data "xorg.conf was backed up to: $timeStampXorg" XORG_BACKED_UP='true' # set correct bus id as last step, note you have to check for . in PCI string: # like this: O1:00.0 and change it to O1:00:0 BUS_ID=$( lspci -n | grep "$CARD_DATA" | egrep -io '^[0-9]{1,2}:[0-9a-z]{1,2}(\.|:)[0-9]' | sed 's/\./:/') # handle explicit assignment of busid to avoid errors echo "${S}Updating ${C}xorg.conf${S} to use the card with this BusID: ${C}$BUS_ID${N}" if [ -n "$BUS_ID" ];then # create a dummy in case it's needed by new xorg system create_section_device pcibusid_hex_to_dec # need to get rid of hex due to xorg error # this is redundant if set above but easier to do for all cases sed -i -r 's/\s*#*\s*BusID.*/\tBusID\t"PCI:'$BUS_ID'"/' $EXXC fi fi fi found='true' break else found='false' fi done break done if [ "$found" != "true" ];then echo "${E}Please select one of the numbers for your choices!${N}" select_card fi } #select_card;exit # this is separated from detect card because it will be used for nv/ati basic card tests set_card() { local foundCard='' card='' # note: select_card has already handled multiple cards on box, so no need to loop it CARD_BRAND=$( echo $CARD_DATA | cut -d ':' -f1 ) case $CARD_BRAND in 10de|12d2) CARD=$NVIDIA foundCard='true' ;; 1002) CARD=$FGLRX foundCard='true' ;; 8086) CARD=$INTEL foundCard='true' ;; 10c8) CARD=$NEOMAGIC foundCard='true' ;; 121a) CARD=$TDFX foundCard='true' ;; *) # this is required to handle unknown card types when forced override is used if [ -n "$NATIVE_OVERRIDE" ];then foundCard='true' fi ;; esac if [ -z "$foundCard" ];then error_handler 254 fi } ## card support information: # nvidia: http://us.download.nvidia.com/XFree86/Linux-x86/1.0-9755/README/appendix-a.html ## pick out the id string for nvidia/fglrx, set all the master variables for nv/fg detect_card_version() { local foundVersion='' version='' found='' card='' cardBrand='' cardNumber='' local isQuad='' is8xxx='' # note: select_card has already handled multiple cards on box, so no need to loop it cardBrand=$( echo $CARD_DATA | cut -d ':' -f1 ) cardNumber=$( echo $CARD_DATA | cut -d ':' -f2 ) case $cardBrand in 10de|12d2) DRIVER_LEGACY=$NV_LEGACY_1 DRIVER_DEFAULT=$NV_DEFAULT DRIVER_TESTING=$NV_TESTING VERSIONS=$NV_VERSIONS OTHER_VERSIONS=$NV_OTHERS CARD_NUMBER=$cardNumber # do some card specific tests to determine generic classes isQuad=$( lspci | grep 'VGA' | grep -i -o 'quadro' ) is8xxx=$( lspci | grep 'VGA' | egrep -o '8[0-9]{3}' ) case $cardNumber in # http://listing.driveragent.com/pci/10de/?q=94c3 # later series # http://listing.driveragent.com/pci/12d2/?q=94c3 # full legacy 0008|0009|0010|0018|0019) error_handler 253 # if card in this list exit LEGACY_LEVEL=0 ;; 0020|0028|0029|002c|002d|00a0|0100|0101|0103|0150|0151|0152|0153|0170) DRIVER_INSTALL=$NV_LEGACY_1 # force this driver for these cards # RENDER_ACCEL='' # set default to false LEGACY_LEVEL=1 ;; 0110|0111|0112|0113|0170|0171|0172|0173|0174|0175|0176|0177|0178|0179|017a|017c|017d|0180|0181|0182|0183|0185|0186|0187|0188|018a|018b|018c|01a0|01f0|0200|0201|0202|0203|0250|0251|0253|0258|0259|025b|0280|0281|0282|0286|0288|0289|028c) DRIVER_INSTALL=$NV_LEGACY_2 LEGACY_LEVEL=2 # RENDER_ACCEL='' # set default to false ;; # This is for the GeForce FX 5xxx series. Not sure about the quadro fx series: # 004d 004e 09d0 009d 00cd 00ce 00fe 019d 019e 0320|0321|0322|0323|0324|0325|0326|0327|0328|0329|032c|032d|0330|0331|0332|0333|0334|0341|0342|0343|0344|0347|0348) DRIVER_INSTALL=$NV_LEGACY_3 LEGACY_LEVEL=3 ;; # 0191|0193) # : # this handles the lack of xvmc support in 8xxx cards # ;; *) # set flags for fully supported non-legacy cards USE_XVMC='true' LEGACY_LEVEL=100 ;; esac # this handles 8xxx xvmc issue if [ -n "$is8xxx" ];then USE_XVMC='' fi # this handles quad cards, whose driver supports both nv legacy and standard cards if [ -n "$isQuad" ];then : # now quad driver is just latest #DRIVER_QUAD=$NV_QUAD #DRIVER_INSTALL=$NV_QUAD fi ;; 1002) DRIVER_LEGACY=$FG_LEGACY DRIVER_DEFAULT=$FG_DEFAULT DRIVER_TESTING=$FG_TESTING VERSIONS=$FG_VERSIONS OTHER_VERSIONS=$FG_OTHERS CARD_NUMBER=$cardNumber case $cardNumber in # fireGL cards, temp no support in fglrx # http://wiki.cchtml.com/index.php/Hardware # note: 4e50 should work with 8.4 driver 3154|3e54|4147|4154|4a4d|4e47|4e4b|4e54|5464|5550|5551|564a|564b|5b64|5d49|5e48|5e49|71C4) LEGACY_LEVEL=0 error_handler 253 ;; # http://listing.driveragent.com/pci/1002/?q=94c3 0544) LEGACY_LEVEL=0 error_handler 253 ;; # removed from list: 4337 - laptop chip 4136|4137|4237|4242|4243|4336|4337|4354|4358|4437|4554|4654|4742|4744|4747|4749|474c|474d|474e|474f|4750|4751|4752|4753|4754|4755|4756|4757|4758|4759|475a|4964|4965|4966|4967|496e|496f|4c42|4c44|4c45|4c46|4c47|4c49|4c4d|4c4e|4c50|4c51|4c52|4c53|4c54|4c57|4c58|4c59|4c5a|4c64|4c65|4c66|4c67|4c6e|4c6f|4d46|4d4c|4f72|4f73) LEGACY_LEVEL=0 error_handler 253 ;; 5041|5042|5043|5044|5045|5046|5047|5048|5049|504a|504b|504c|504d|504e|504f|5050|5051|5052|5053|5054|5055|5056|5057|5058|5144|5145|5146|5147|5148|5149|514a|514b|514c|514d|514e|514f|5154|5155|5157|5158|5159|515a|515e|515f|5168|5169|516a|516b|516c|516d|516f|5245|5246|5247|524b|524c|5345|5346|5347|5348|534b|534c|534d|534e|5354|5446|544c|5452|5453|5454|5455|5654|5655|5656|5833|5834|5835|5838|5854|5874|5940|5941|5942|5944|5960|5961|5962|5964|5965|5969|5c41|5c43|5c61|5c63|5d44) LEGACY_LEVEL=0 error_handler 253 ;; 728c|7834|7835) LEGACY_LEVEL=0 error_handler 253 ;; *) # if no working driver via standard ati installer. Here we're also handling # the monthly releases, so users can do an experimental test if needed # if [ "$DEBIAN_FLAG" == 'true' -a "$B_TESTING_1" != 'true' ] LEGACY_LEVEL=100 if [ "$DEBIAN_FLAG" == 'true' ];then USE_DEBIAN_DRIVER='true' fi ;; esac ;; # set NATIVE_DRIVER so script fires correctly # intel | neomagic | 3dfx 8086|10c8|121a) CARD_NUMBER=$cardNumber NATIVE_DRIVER='true' ;; esac #echo $cardNumber } ######################################################################## #### script utilities #### ------------------------------------------------------------------- kernel_string_info() { # The kernel variables stuff needs to be in a separate function to get data from # either the running kernel or the new installed kernel if [ -n "$INSTALL_TO_KERNEL" ];then KERNEL_VERSION=$INSTALL_TO_KERNEL else KERNEL_VERSION=$( uname -r ) # full kernel name fi IS_SIDUX_KERNEL=$( echo $KERNEL_VERSION | grep -e "[\.|-]slh\(64\)\?[\.|-]" ) IS_XEN=$( grep -i 'CONFIG_XEN=y' /boot/config-$KERNEL_VERSION ) KERNEL_BASE=$( echo $KERNEL_VERSION | cut -d '.' -f 1-2 ) # like: 2.6 KERNEL_THREE=$( echo $KERNEL_VERSION | cut -d '-' -f 1 | cut -d '.' -f 1-3 ) # like: 2.6.19 KERNEL_THIRD=$( echo $KERNEL_VERSION | cut -d '-' -f 1 | cut -d '.' -f 3 ) # like: 19, for math use } # The best test I've found so far to check whether the kernel exists or not: test_install_kernel_version() { if [ ! -d /lib/modules/$INSTALL_TO_KERNEL ];then echo "${S}These are your currently installed kernels:${C}" ls /lib/modules echo ${N} error_handler 232 $INSTALL_TO_KERNEL #comment the line above to debug the kernel_string_info function - Also uncomment the debug lines in that function # it passed the test else kernel_string_info fi } print_information() { local scriptVersion=$( egrep -o -m 1 "(version:).*" $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2 ) local scriptDate=$( egrep -o -m 1 '(Date:).*' $SCRIPT_HOME/$SCRIPT_NAME | cut -d ' ' -f 2-4 ) #local cardInfo=$( lspci | gawk -F': ' '/VGA compatible controller.*: / { print $NF }' | sed -r 's%(ATI\sTechnologies\sInc\s|nVidia\sCorporation\s)(.*)%\2%' ) local cardInfo=$( lspci | awk -F': ' '/VGA compatible controller.*: / { print $NF }' | sed -r 's%(ATI\s|nVidia\s|Intel\s)(Technologies\sInc\s|Corporation\s|Unknown\sdevice){1,2}(.*)%\1\3%g' ) local cardRam='' cardVendor='' busId='' # we need the real busid, not the xorg one busId=$( lspci -n | grep "$CARD_DATA" | egrep -io '^[0-9]{1,2}:[0-9a-z]{1,2}(\.|:)[0-9]' ) if [ -n "$busId" ];then cardRam=$( lspci -v -s $busId 2>/dev/null | egrep '.*Memory[[:space:]].*[[:space:]]prefetchable.*\[size=([0-9]+)M\]' | sed -r 's/.*Memory[[:space:]].*[[:space:]]prefetchable.*\[size=([0-9]+)M\]/\1/' ) cardVendor=$( lspci -v -s $busId 2>/dev/null | egrep '.*Subsystem:[[:space:]]*(.*)' | sed -r 's/.*Subsystem:[[:space:]]*(.*)/\1/' | sed 's/[dD]evice.*$//g' | sed 's/[uU]nknown//g' ) fi echo ${M}$LINE echo " ${M}$SCRIPT_NAME${S} :: version: ${C}$scriptVersion${S} :: last updated: ${C}$scriptDate" echo ${M}$LINE echo " ${S}graphics card information:" echo " ${S}series: ${C}$cardInfo" if [ -n "$cardVendor" ];then echo " ${S}vendor: ${C}$cardVendor" fi if [ -n "$cardRam" ];then echo " ${S}ram: ${C}$cardRam MegaBytes ${S}(note: not accurate for built in graphics)" fi echo ${M}$LINE${N} } #print_information basic_startup_tests() { local nonDebianPattern='(sidux|opera|debian-multimedia|skype|swiftfox|virtualbox)' # these tests will be improved over time, but are ok for now local isEtch=$( grep -is '^4.' $EDV ) local isLennyStable=$( grep -is '^5.' $EDV ) local isLennyTesting=$( grep -is '^lenny/sid' $EDV ) local isSqueezeTesting=$( grep -is '^squeeze/sid' $EDV ) local isStable=$( egrep -siw '^[[:space:]]*deb' $EAS $EAS.d/*.list | egrep -iv "$nonDebianPattern" | egrep -icw '(stable|etch)' ) local isTesting=$( egrep -siw '^[[:space:]]*deb' $EAS $EAS.d/*.list | egrep -iv "$nonDebianPattern" | egrep -icw '(testing)' ) local isUnstable=$( egrep -siw '^[[:space:]]*deb' $EAS $EAS.d/*.list | egrep -iv "$nonDebianPattern" | egrep -icw '(sid|unstable)' ) ### basic system requirements for this script to run, first so user doesn't ### have to be root or out of x to get basic failure information # make sure that it's a debian based system if [ ! -f "$EDV" ];then error_handler 252 fi # no ubuntu support if [ "$( cat /etc/issue | grep -i -c 'buntu' )" -gt 0 ];then error_handler 248 fi # make sure Xorg is installed if [ -z "$( which Xorg )" ];then error_handler 244 fi # make sure xorg.conf exists, with xorg > 1.4 exception to handle null xorg.conf if [ ! -f $EXXC -a -z "$( echo $X_VERSION | egrep '[1-2]\.[0-9]' )" ];then error_handler 249 fi # double check only 2.6 series kernels if [ "$KERNEL_BASE" != '2.6' ];then error_handler 243 fi ### basic execute requirements cd $SCRIPT_HOME if [ "$(whoami)" != 'root' ];then error_handler 251 fi cleanup_temp_files # this allows users to update in x, for example, to see latest drivers if [ "$FORCE_UPDATE" == 'true' ];then check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD" 'default server' fi # only support current systems, xorg >= 7.1/1.x if [ -z "$X_VERSION" ];then error_handler 242 fi # this corrects a stupid mistake I made rm -f *-sgfxi.log # was creating log files in /usr/local/bin # test to see if any dm is running, we'll shutdown all wm later though if [ -n "$DISPLAY" -a "$SKIP_X_TEST" != 'true' ];then error_handler 250 fi # set system type. This test will never be perfect, but it's a good approximation if [ -n "$isEtch" -o -n "$isLennyStable" ] || [ "$isStable" -gt 0 -a "$isUnstable" -eq 0 -a "$isTesting" -eq 0 ];then if [ -n "$isEtch" ];then SYSTEM_BASE='etch' else SYSTEM_BASE='stable' fi elif [ "$isUnstable" -eq 0 ] && [ -n "$isLennyTesting" -o -n "$isSqueezeTesting" -o "$isTesting" -gt 0 ];then SYSTEM_BASE='testing' else SYSTEM_BASE='sid' fi } # handles bug in stub installer that leaves tempfiles uncleaned cleanup_temp_files() { eval $LOGUS local all_files="" slxorg='sgfxi-lib-xorg' # Note: if * is in "" the wildcard does not work # /dev/null handles case where no temp or original file exists all_files=$( ls "${SCRIPT_NAME}."* 2> /dev/null ) # make sure stuff exists, rm files if [ -n "$all_files" ];then rm -f $all_files fi if [ -f $slxorg ];then rm -f $slxorg # clean up old xorg lib file fi eval $LOGUE } check_install_tools() { eval $LOGPS # nvidia and fglrx tools if [ ! -x /usr/bin/module-assistant ];then install_package 'module-assistant' fi if [ ! -d /usr/share/build-essential ];then install_package 'build-essential' fi if [ -z "$( which logrotate )" ];then install_package 'logrotate' fi if [ "$CARD" == $NVIDIA ];then : # fglrx tools and tests elif [ "$CARD" == $FGLRX ];then if [ ! -x /usr/bin/dh_testdir ];then install_package 'debhelper' fi if [ ! -f /usr/lib/libstdc++.so.5 ];then install_package 'libstdc++5' fi # presence of this package will break fglrx install if [ -n "$( dpkg -l | grep 'dpkg-cross' )" ];then remove_package 'dpkg-cross' $CARD fi # force update of xserver-xorg-core package to handle 8.37.6 update # not for now... # install_package xserver-xorg-core fi if [ -f /etc/modutils/1alsa ];then mv /lib/modules/extra/alsa /lib/modules/$KERNEL_VERSION/ rm -f /etc/modutils/1alsa depmod $KERNEL_VERSION -a fi eval $LOGPE } check_apt_aptitude() { eval $LOGUS local opt='' managers='apt-get aptitude quit' local aptPref=$( get_set_prefs 'get' 'apt-type' | cut -d '=' -f 2 | egrep '^(apt-get|aptitude)$' ) if [ -f /var/log/aptitude ];then if [ -z "$aptPref" ];then echo ${S}$LINE echo "${S}It appears you are using aptitude. It is not good to mix apt-get and aptitude." echo "Please pick your preferred package manager before you continue, or exit now." echo echo "Your selection (for example: ${C}apt-type=apt-get${S}) will be stored in ${C}/etc/smxi.conf${S}" echo "${C}smxi${S} will also use this choice for its default package manager, so make sure it's correct." echo $LINE${N} select opt in $managers do case $opt in apt-get|aptitude) APT_TYPE=$opt log_function_data "Selected package manager: $opt" get_set_prefs 'set' "apt-type=$opt" ;; quit) echo "${S}Ok, figure it out and try again later...${N}" exit 0 ;; *) echo "${E}You have to pick one before you can continue!${N}" ask_apt_aptitude ;; esac break done else # set apt type APT_TYPE=$aptPref fi if [ "$APT_TYPE" == 'aptitude' ];then WITHOUT_RECOMMENDS='--without-recommends' fi fi eval $LOGUE } # args: $1 - get/set; $2 - prefname get_set_prefs() { eval $LOGUS local etcsm='/etc/smxi.conf' retValue='' name='' value='' case $1 in get) retValue=$( grep -s $2 $etcsm ) echo $retValue log_function_data "Return value: $retValue" ;; set) touch $etcsm # test = first, this will handle the base name and anything else name=$( cut -d '=' -f 1 <<< $2 ) # check to see if it's there, if it is, it must be a = type thing if [ -z "$( grep -s $name $etcsm )" ];then echo $2 >> $etcsm log_function_data "Added $2 to $etcsm" else sed -i "s/$name.*/$2/" $etcsm log_function_data "Updated $name to $2 in $etcsm" fi ;; esac eval $LOGUE } # arg: $1 - package name; $2 - /experimental/unstable/testing/stable; $3 - --reinstall # optional args. Note that if you use 3, you have to set 2 by '' if blank. install_package() { eval $LOGUS local distroVersion='' optionalArgs='' doYes='-y' local useUntrusted='--allow-unauthenticated' install='install' local packageInstalled=$( dpkg -l | grep "$1" | cut -d ' ' -f 3 ) if [ "$UPDATED" != 'true' ];then $APT_TYPE update && UPDATED='true' fi if [ "$APT_TYPE" == 'aptitude' ];then if [ "$SYSTEM_BASE" == 'etch' ];then useUntrusted='' # etch aptitude doesn't support this else useUntrusted='--allow-untrusted' fi doYes='' fi # this will force install of sid to get rid of experimental if required if [ -n "$2" ];then distroVersion="/$2" # --force-yesrequird to avoid apt downgrade error fi # only do --reinstall if arg is set and package is installed case "$3" in --reinstall) if [ -n "$packageInstalled" ];then if [ "$APT_TYPE" == 'aptitude' ];then optionalArgs='' install='reinstall' else optionalArgs=$3 fi fi ;; *) : ;; esac # then install the package with all options $APT_TYPE $install $useUntrusted $WITHOUT_RECOMMENDS $doYes $optionalArgs $1$distroVersion || error_handler 200 $1 eval $LOGUE } # install_package nano '' --reinstall remove_package() { eval $LOGUS local response='' package='' echo ${M}$LINE echo "You will need to remove the following package(s): ${C}$1" echo "${M}in order to proceed with your ${C}$2${M} driver install${N}" echo $LINE for package in $1 do if [ -n "$( dpkg -l | grep "$package" )" ];then echo "${S}Removing ${C}$package${S}...${N}" $APT_TYPE purge $package || error_handler 190 "$package" else echo "${S}The package ${C}$package${S} is not installed, continuing...${N}" fi done echo "${S}Package(s) removed successfully, continuing with driver install.${N}" eval $LOGUE } update_to_nonfree_sources() { eval $LOGPS local isFree=0 i='' counter=0 local eas='/etc/apt/sources.list' local easdl='/etc/apt/sources.list.d/debian.list' local eassl='/etc/apt/sources.list.d/sidux.list' # loop through possible files to update for i in $eas $easdl $eassl do if [ -f "$i" ];then counter=$( egrep -c 'deb.*debian\.org.*(contrib|non-free)' $i ) isFree=$(( $counter + $isFree )) fi done if [ "$isFree" -eq 0 ];then for i in $eas $easdl $eassl do if [ -f "$i" ];then echo "${S}Updating your ${C}$i${S} to use non-free / contrib now...${N}" sed -i -r 's%(#?deb.*(debian\.org|sidux\.com|sidux\.net|debian\.tu-bs\.de|mirrorservice\.org|heanet\.ie|spline\.de|sunsite\.utk\.edu|leg\.uct\.ac\.za|mirror\.aarnet\.edu\.au).*\s(main|fix\.main))(\s*)(non-free.*|contrib.*)*%\1 contrib non-free%' $i # the second test requires the results of the first to work # note that spaces are required for this to work more reliably for most patterns sed -i -r 's%(#?deb.*(sidux\.com|sidux\.net|debian\.tu-bs\.de|mirrorservice\.org|heanet\.ie|spline\.de|sunsite\.utk\.edu|ftp-mirror\.internap\.com|ftp\.tw.debian\.org|leg\.uct\.ac\.za|mirror\.aarnet\.edu\.au).*\snon-free)%\1 firmware fix.contrib fix.non-free %' $i fi done $APT_TYPE update && UPDATED='true' # need to refresh fi eval $LOGPE } # args: $1 script to get/check; $2 - which download source to use # $3 - extra message; $4 - repeat, to only retest download failure once check_update_script() { local fileNameTemp="$( mktemp -p $SCRIPT_HOME/ $1.XXXXXXXXXX )" local isGood='' uArgs='' downloadUrl=$2 extraText='' if [ -n "$( egrep '(dev|svn|alt)' <<< $3 )" ];then extraText="${C}$3:\n$2${S}" else extraText="${C}$3${S}" fi cd $SCRIPT_HOME # make sure we're in the right place if [ -f "$fileNameTemp" ];then rm -f $fileNameTemp # remove the temp file, should never fire, but why not? fi # if newer version, download / replace lib file case $1 in $SCRIPT_NAME) if [ "$FORCE_UPDATE" != 'true' -a "$4" != 'repeat' -a -n "$( grep 'echpat' <<< $2 )" ];then uArgs='?u' fi echo -e "${S}Updating ${C}$SCRIPT_NAME${S} now using the $extraText${N}" wget -q -O$fileNameTemp $downloadUrl$1$uArgs || error_handler 198 $1 # all smxi files have this string as last line, so if it's there, the file should usually # run fine, except for weird fringe cases where the ascii file is corrupted partially isGood=$( grep '##\*\*EOF\*\*##' $fileNameTemp ) if [ -n "$isGood" ];then mv -f $fileNameTemp $1 chmod 705 $1 if [ "$FORCE_UPDATE" != 'true' ];then ./$1 -R$START_OPTIONS else print_information echo "${C}$SCRIPT_NAME${S} was successfully updated. Please start the script again" echo "to access the latest features and drivers. Exiting now.${N}" fi exit 0 else # dump the bad file rm -f $fileNameTemp if [ "$4" != 'repeat' ];then # let's try this once again to make sure it wasn't just a temp problem echo -e "${E}The file ${C}$1${E} did not download correctly from:\n$2\nRetrying download now...${N}" check_update_script "$1" "$2" "$3" 'repeat' else error_handler 231 $1 fi fi ;; # I'm only going to load this stuff one time per file so I won't # have to worry about rechecking and multi downloads etc *) if [ "$SKIP_WGET" != 'true' ];then wget -q -O$1 $downloadUrl$1 || error_handler 198 $2$1 fi if [ ! -s $1 ];then error_handler 199 $1 # if no file, exit with file name + error fi source ./$1 # load the library file ;; esac } # args: $1 patch file to apply apply_patch_file() { eval $LOGUS local patchFile=$1 local patchDirectory="$INSTALL_WORKING_DIR$INSTALL_DIRECTORY/" ## this can be changed to branches with -! 20 or -! 21 local patchUrl="${PATCH_DOWNLOAD}patches/$patchFile" cd $INSTALL_WORKING_DIR$INSTALL_DIRECTORY # first change to the correct directory log_function_data "Patch File Dir: $INSTALL_WORKING_DIR$INSTALL_DIRECTORY" log_function_data "Patch URL: $patchUrl" echo "${S}Retrieving patch ${C}$patchFile${S}...${N}" wget -q -O $patchDirectory$patchFile $patchUrl || error_handler 180 $patchFile if [ -f $patchFile ];then log_function_data "Patch File: $patchDirectory$patchFile" echo "${S}Running patch ${C}$patchFile${S}...${N}" patch -p0 < $patchDirectory$patchFile || error_handler 179 $patchFile # remove the patch file after use just to keep the stuff neat long term rm -f $patchFile echo "${S}Patching completed...${N}" else error_handler 181 $patchFile fi eval $LOGUE } # args: $1 testing or standard; $2 function/feature name; $3 function name print_information_continue() { eval $LOGUS local response='' case $1 in standard|info) echo -e "${S}$2" ;; esac if [ "$1" == 'standard' ];then if [ "$AUTORUN" != 'true' ];then echo "${M}Hit ${C}${M} to continue, or ${C}x + ${M} to exit now if there is an error.${N}" read response case $response in x|X) error_handler 100 $FUNCNAME ;; esac fi fi eval $LOGUE } create_log() { local cardString=$( lspci | grep -i 'vga ' | cut -d ':' -f 3 ) local sgfxiVersion=$( grep 'version:' $SCRIPT_NAME | grep -o "[0-9]*\.[0-9]*\.[0-9]*" ) # check and create log file: if [ ! -d $LOG_FILE_DIR ];then mkdir $LOG_FILE_DIR fi # cleanup legacy logs rm -f ${LOG_FILE_DIR}200*-sgfxi.log # check and create logfile: LOG_FILE=$LOG_FILE_DIR$LOG_FILE if [ ! -f $SCRIPT_ROTATE ];then echo "$LOG_FILE { rotate 8 create size 10k } " > $SCRIPT_ROTATE else # update if needed if [ -n "$( grep ' 120k' $SCRIPT_ROTATE )" ];then sed -i 's/rotate[[:space:]]4/rotate 8/' $SCRIPT_ROTATE sed -i 's/size[[:space:]]120k/size 10k/' $SCRIPT_ROTATE fi fi touch $LOG_FILE # make sure there's one there for rotate to look at if [ -n "$( which logrotate )" ];then logrotate $SCRIPT_ROTATE fi touch $LOG_FILE # and if rotated, need a new one echo "=========================================================" >> $LOG_FILE echo "START $SCRIPT_NAME LOGGING:" >> $LOG_FILE echo "=========================================================" >> $LOG_FILE echo "Script started: $( date +%Y-%m-%d-%H:%M:%S )" >> $LOG_FILE echo "Video Card Information:$cardString" >> $LOG_FILE echo "Video Card Type: $CARD_BRAND" >> $LOG_FILE echo "Video Card Number: $CARD_NUMBER" >> $LOG_FILE echo "Installing driver to kernel: $KERNEL_VERSION" >> $LOG_FILE if [ -n "$INSTALL_TO_KERNEL" ];then echo "Running install from Kernel: $(uname -r)" >> $LOG_FILE fi echo "$SCRIPT_NAME script version: $sgfxiVersion" >> $LOG_FILE echo "$SCRIPT_NAME start options: $START_OPTIONS" >> $LOG_FILE echo "SYSTEM_BASE: $SYSTEM_BASE" >> $LOG_FILE echo "=========================================================" >> $LOG_FILE # it's important to log these in case there's some issue or bug in the values if [ -f $SM_VALUES ];then echo -e "Begin User Set $SM_VALUES:\n$( cat $SM_VALUES)\nEnd User Set Values" >> $LOG_FILE fi echo -e "INSTALL_TO_KERNEL: $INSTALL_TO_KERNEL\nKERNEL_VERSION: $KERNEL_VERSION\nKERNEL_BASE: $KERNEL_BASE\nKERNEL_THREE: $KERNEL_THREE\nKERNEL_THIRD: $KERNEL_THIRD\nIS_XEN: $IS_XEN" >> $LOG_FILE LOGGING_STARTED='true' } # $1 type or data; $2 is function; $3 - function args, optional log_function_data() { local funcInfo='' logSpacer=' ' if [ "$PRINT_VER" != 'true' ];then case $1 in ps) funcInfo="Function: $2 - Primary: Start" ;; pe) funcInfo="Function: $2 - Primary: End" ;; us) funcInfo="Function: $2 - Utility: Start" ;; ue) funcInfo="Function: $2 - Utility: End" ;; esac if [ -n "$funcInfo" ];then log_writer "$funcInfo" else log_writer "${logSpacer}$1" fi if [ -n "$3" ];then log_writer "${logSpacer}Args: $3" fi fi } # args: $1 - data to write to logfile. Note that the function is always logged # via function_logging first, and other relevant globals are set there as well log_writer() { # this handles first line indents, all other indents must be set in message data # like so: message="some problem... \n${LOG_INDENT}more problem stuff..." if [ "$LOGGING_STARTED" == 'true' ];then # strip out escape color code, if any. Method by dzz of sidux, thanks ;-) echo -e "$1" | sed 's/\x1b\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g' >> $LOG_FILE fi } ######################################################################## #### Core graphic driver installer functions #### ------------------------------------------------------------------- ### ------------------------------------------------------------------- ### Native Driver installer section ### ------------------------------------------------------------------- # this bypasses core binary installers and just runs the required pieces install_native_driver() { eval $LOGPS local xorgBase='xserver-xorg-video-' xorgNv='nv' xorgAti='ati' xorgIntel='intel' local xorgDriver='' driver='' currentlyInstalled='' local driverInstall='' experimentalText='' if [ "$EXPERIMENTAL" == 'true' ];then experimentalText=' experimental' fi # if [ "$CARD" == $NVIDIA -o "$CARD" == $FGLRX -o "$CARD" == $INTEL -o -n "$NATIVE_OVERRIDE" ];then eval $LOGPS case $CARD in $NVIDIA) xorgDriver=$xorgNv ;; # note: radeon uses ati driver, so don't try to install xorg radeon $FGLRX) xorgDriver=$xorgAti ;; $INTEL) xorgDriver=$xorgIntel ;; esac # driverInstall is just for output text for user to know what driver script installs driverInstall=$xorgDriver # replace with override if it's been set if [ -n "$NATIVE_OVERRIDE" -a "$NATIVE_OVERRIDE" != 'radeon' ];then xorgDriver=$NATIVE_OVERRIDE driverInstall=$NATIVE_OVERRIDE elif [ "$NATIVE_OVERRIDE" == 'radeon' ];then driverInstall=$NATIVE_OVERRIDE fi # driver is the actual driver xorg will use driver=$xorgBase$xorgDriver if [ "$PRINT_VER" != 'true' ];then print_information_continue 'standard' "The graphics installer will be installing the${C}$experimentalText Free xorg${S} driver: ${C}$driverInstall${N}" else exit 0 # this is required for smxi native driver tests fi x_start_stop_master stop ## cleanup up old stuff pre_extract_cleanup preinstall_cleanup # this is required to do radeon xorg driver native_driver_install_keep currentlyInstalled=$( COLUMNS=200 dpkg -l | cut -d ' ' -f 3 | grep "$driver" ) case $CARD in $FGLRX) # prep_native_driver # remove all the possible packages installed by experimental if [ "$EXPERIMENTAL" == 'true' ];then # echo "${S}There is no current experimental ${C}$driver${S}. Installing sid ${C}$driver${N}" # install_package $driver # install_package libdrm2 unstable # this may need some work to undo it echo "${S}Installing experimental driver ${C}$driver${S} now...${N}" native_driver_experimental "$driver" # this will clean up experimental stuff if present else echo "${S}Reinstalling driver ${C}$driver${S} now...${N}" install_package $driver # install_package libdrm2 unstable # this may need some work to undo it fi ;; *) ## install driver only if needed, don't want to force an unwanted xorg update if [ -z "$currentlyInstalled" ];then # intel i810 # libc6 (>= 2.3.6-6), libdrm2, libexpat1 (>= 1.95.8), libgl1-mesa-glx (= 6.5.1-0.6) echo "${S}Installing missing driver ${C}$driver${S} now...${N}" install_package $driver else echo "${S}Using your currently installed ${C}$driver${S} driver...${N}" fi ;; esac ## clean / update xorg, this is only to change driver to ati/nv, no full xorg conf yet. update_xorg process_xvmc # this will restore xvmc defaults if nvidia stuff was being used eval $LOGPE ## and finish it up x_start_stop_master start exit 0 # just exit here in case something weird goes wrong with xorg start else error_handler 254 # this is redundant, but I'm leaving it as a fail safe fi eval $LOGPE } native_driver_install_keep() { eval $LOGUS local lgmd='libgl1-mesa-dri' ldrm='libdrm2' if [ "$NATIVE_OVERRIDE" == 'radeon' ];then if [ -z "$( dpkg -l | grep "$lgmd" )" ];then install_package $lgmd fi if [ -z "$( dpkg -l | grep "$ldrm" )" ];then install_package $ldrm fi if [ -n "$( which deborphan )" ];then # doing one at a time because if one is already on keep, # trying to add both will fail deborphan --add-keep $lgmd > /dev/null deborphan --add-keep $ldrm > /dev/null fi fi eval $LOGUE } # args: $1 $driver; $2 $currentlyInstalled native_driver_experimental() { eval $LOGPS if [ "$CARD" == $FGLRX ];then # step one, check and install basic drivers if [ -n "$EXPERIMENTAL_XORG_ATI" ];then echo "${S}Starting experimental driver ${C}$1${S} install now...${N}" download_install_package freedesktop-ati unset packageExists else error_handler 187 exp-xorg-ati fi # step 2, if required, check and install extra packages if [ "$EXTRA_EXPERIMENTAL" == 'true' -a -n "$EXPERIMENTAL_LIBDRM2" ];then echo "${S}Adding experimental components for ${C}$1${S} now...${N}" download_install_package freedesktop-ati-drm2 download_install_package freedesktop-ati-drm-dev unset packageExists else error_handler 187 exp-drm2 fi fi eval $LOGPE } # this is for non-standard debs, and other stuff, for experimental use primarily download_install_package() { eval $LOGUS local packageToInstall='' url='' systemType='_i386.deb' shortPackage='' if [ "$BITS" == '64' ];then systemType='_amd64.deb' fi case $1 in freedesktop-ati) packageToInstall=$EXPERIMENTAL_XORG_ATI$systemType ;; freedesktop-ati-drm2) packageToInstall=$EXPERIMENTAL_LIBDRM2$systemType ;; freedesktop-ati-drm-dev) packageToInstall=$EXPERIMENTAL_LIBDRM_DEV$systemType ;; esac url=$SCRIPT_DOWNLOAD'ati-drivers/'$packageToInstall if [ -z "$packageToInstall" ];then error_handler 187 download-package fi # slice out first part of name for package display purposes shortPackage=$( echo $packageToInstall | cut -d '_' -f 1 ) echo "${S}Downloading Experimental package ${C}$shortPackage${S} now...${N}" wget -Nc $url || error_handler 189 $packageToInstall if [ -s "$packageToInstall" ];then echo "${S}Experimental package ${C}$shortPackage${S} downloaded successfully, installing now.${N}" dpkg -i $packageToInstall rm -f $packageToInstall else #rm -f $packageToInstall error_handler 188 $packageToInstall fi eval $LOGUE } prep_native_driver() { eval $LOGUS local xxva='xserver-xorg-video-ati' ldrmd='libdrm-dev' local packageList='' case $CARD in $FGLRX) packageList="$xxva $ldrmd" ;; esac eval $LOGUE remove_package "$packageList" $xxva } ### ------------------------------------------------------------------- ### Non-free Driver installer section ### ------------------------------------------------------------------- set_cpu_data() { eval $LOGUS case $CARD in $NVIDIA) if [ "$BITS" == '64' ];then ARCH='_64' fi ;; $FGLRX) # this is legacy, no longer needed but in case ati changes again leave it ARCH='i386' # default value if [ "$BITS" == '64' ];then ARCH='amd64' fi ;; esac if [ "$PRINT_VER" != 'true' ];then log_function_data "BITS: $BITS - arch: $ARCH" fi eval $LOGUE } ## test if the driver to be installed is in the list of supported drivers ## advanced tests occur in driver_support_tests, patches set in run_patches check_supported_driver() { eval $LOGUS local isGood='' pattern='[0-9]{4}' local drivers="$DRIVER_DEFAULT:$VERSIONS:$DRIVER_TESTING:$OTHER_VERSIONS:$DRIVER_QUAD" if [ -n "$DRIVER_OVERRIDE" ];then isGood=$( echo $drivers | grep "$DRIVER_OVERRIDE" ) if [ -z "$isGood" ];then error_handler 241 $DRIVER_OVERRIDE fi fi if [ "$1" == 'last-check' ];then isGood=$( echo $drivers | grep "$DRIVER_DEFAULT" ) if [ -z "$isGood" ];then error_handler 240 $DRIVER_DEFAULT fi fi eval $LOGUE } set_version() { eval $LOGPS local response='' printDriver='' newKernelText='' # I'm forcing special cases to override the defaults so the data # printed out will show what drivers are supported if [ -n "$DRIVER_INSTALL" ];then DRIVER_DEFAULT=$DRIVER_INSTALL fi # this is only for du output :: this has to go before assigning -o version number if [ "$PRINT_VER" == 'true' ];then # echo the basic list: if [ "$USE_DEBIAN_DRIVER" != 'true' ];then echo $DRIVER_DEFAULT':'$VERSIONS else # note: because sometimes I'm turning off fglrx run install due to failure # that leaves only debian fglrx to install echo $DEBIAN_FGLRX fi exit 0 fi if [ -n "$DRIVER_OVERRIDE" ];then DRIVER_DEFAULT=$DRIVER_OVERRIDE fi # error_handler 246 $DRIVER_DEFAULT # for unsupported cards if [ "$USE_DEBIAN_DRIVER" != 'true' ];then check_supported_driver last-check else case $CARD in $FGLRX) DRIVER_DEFAULT=$DEBIAN_FGLRX ;; $NVIDIA) DRIVER_DEFAULT=$DEBIAN_NVIDIA ;; esac fi if [ "$SM_INSTALL" != 'true' -a -n "$START_OPTIONS_PRINT" ];then print_information_continue 'info' "You are using the following options:\n$START_OPTIONS_PRINT" elif [ "$SM_INSTALL" == 'true' -a -n "$INSTALL_TO_KERNEL" ];then newKernelText="\n${S}onto the kernel: ${C}$INSTALL_TO_KERNEL${N}" fi print_information_continue 'standard' "The graphics installer will be installing the ${C}$CARD${S} driver: ${C}$DRIVER_DEFAULT${N}$newKernelText" log_function_data "Installing this driver: $DRIVER_DEFAULT" eval $LOGPE # test for support driver_support_tests supported-driver } # args: $1 - which fix. Holds miscellaneous highly specific fixes, created as needed misc_fixes() { eval $LOGUS case $1 in nvidia-24-link) local headersDir="/usr/src/linux-headers-$KERNEL_VERSION/include" # I don't know why the -e/f tests fail, I thought -e means exists at all... if [ -L "$headersDir/asm" -o -e "$headersDir/asm" ];then rm -f $headersDir/asm fi echo "${S}Creating symbolic link ${C}asm-x86 asm${S}...${N}" ln -sf $headersDir/asm-x86 $headersDir/asm || error_handler 233 "link -s asm-x86 asm" if [ ! -e $headersDir/asm-i386 -a "$BITS" == '32' ];then log_function_data "Creating soft link asm-x86 asm-i386 in $headersDir" echo "${S}Creating symbolic link ${C}asm-x86 asm-i386${S}...${N}" ln -s $headersDir/asm-x86 $headersDir/asm-i386 || error_handler 233 "link -s asm-x86 asm-i386" log_function_data "Link successfully created." else log_function_data "link asm-x86 asm-i386 in $headersDir already exists" fi ;; esac eval $LOGUE } set_download_info() { eval $LOGPS local packageName='' downloadUrl='' response='' nvPkgNo=0 case $CARD in $NVIDIA) # this tweak thanks to ajw1980, who pointed out that pkg2 installs # 32 bit compatibility libs in 64 bit without further fuss. if [ "$BITS" == '64' ];then nvPkgNo=2 fi # set the package name, .run is added to it when it's needed DRIVER_FILE="NVIDIA-Linux-x86$ARCH-$DRIVER_DEFAULT-pkg$nvPkgNo" downloadUrl="$NVIDIA_DOWNLOAD_SITE/XFree86/Linux-x86$ARCH/$DRIVER_DEFAULT/" ;; $FGLRX) # set driver package name # DRIVER_FILE="ati-driver-installer-$DRIVER_DEFAULT-$CPU" DRIVER_FILE="ati-driver-installer-$DRIVER_DEFAULT-x86.x86_64" # set download path downloadUrl='http://www2.ati.com/drivers/linux/' ;; esac log_function_data "download url: $downloadUrl - driver file: $DRIVER_FILE" eval $LOGPE download_extract_driver $downloadUrl $DRIVER_FILE } # arg: $1 install package to remove pre_extract_cleanup() { eval $LOGUS if [ "$NATIVE_DRIVER" != 'true' ];then rm -rf $1 # this removes nvidia install dir if present fi # clean up any old stuff that might be left from last install, fglrx stuff # note: with 8.35.x ati switched to a randomly generated directory name # using the format fgrlx-install.FRGDXE rm -rf $FG_WORKING_DIR* /tmp/fglrx* rm -f /etc/fglrxrc /etc/fglrxprofiles.csv fglrx* eval $LOGUE } # args: $1 download url; $2 package name download_extract_driver() { eval $LOGPS local runPackage=$2'.run' errorTemp='' atiRef='' # this was needed to avoid some test from ati... not needed anymore last I tried case $CARD in $FGLRX) atiRef='--referer=ati.com ' ;; esac cd $INSTALL_WORKING_DIR pre_extract_cleanup $2 ## $2 will only apply to nvidia install dir removal # test for existing downloaded version, then download, error if download fails # have to keep it in a clean if to avoid error if [ ! -f $runPackage ];then echo "${S}Downloading ${C}$runPackage${S} from ${C}$1${S}...${N}" wget -Nc $atiRef$1$runPackage || error_handler 197 $runPackage else echo "${S}Using the previously downloaded installer package: ${C}$runPackage${N}" fi echo "${S}Extracting ${C}$runPackage${S}...${N}" case $CARD in $NVIDIA) # extract it, on error delete and call error handling bash ./$runPackage --extract-only 1>> $LOG_FILE 2>> $LOG_FILE errorTemp="$?" ;; $FGLRX) LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= bash ./$runPackage --extract 1>> $LOG_FILE 2>> $LOG_FILE errorTemp="$?" ;; esac if [ "$errorTemp" -gt 0 -a "$B_SKIP_FUNCTION" != 'true' ];then rm -f $runPackage error_handler 196 $runPackage fi eval $LOGPE } prep_install() { eval $LOGPS local gccVersion=$( egrep -io 'gcc[[:space:]]*version[[:space:]]*[4-6]\.[0-9]{1,2}' /proc/version | egrep -o '[4-6]\.[0-9]{1,2}' ) local ubgv="/usr/bin/gcc-$gccVersion" # We now need to do active detection of fglrx-install directory name due to # silly random directory naming schema ati just started with 8.35.5 # hint to ATI: just copy nvidia, they do it better than you! case $CARD in $NVIDIA) INSTALL_DIRECTORY=$DRIVER_FILE ;; $FGLRX) INSTALL_DIRECTORY=$( ls | grep "$FG_WORKING_DIR" ) ;; esac echo "${S}Preparing driver install...${N}" if [ -f /etc/debian_version -a ! -f /etc/sidux-version ];then m-a -i prepare fi cd $INSTALL_WORKING_DIR$INSTALL_DIRECTORY if [ -x "$ubgv" ];then export CC=$ubgv else error_handler 230 "$ubgv" fi eval $LOGPE } preinstall_cleanup() { eval $LOGPS local oldNvidia='' divertedPackages='' installer='nvidia-installer' oldFglrx='' echo "${S}Running preinstall cleanup...${N}" # this is not set as a path if native driver install if [ "$NATIVE_DRIVER" != 'true' ];then cd $INSTALL_WORKING_DIR$INSTALL_DIRECTORY fi ####### NVIDIA removal... # double check, clean up anything left after uninstaller runs rm -f /usr/src/nvidia* 1>> $LOG_FILE 2>> $LOG_FILE rm -rf /usr/src/modules/nvidia* 1>> $LOG_FILE 2>> $LOG_FILE if [ -n "$( lsmod | grep '^nvidia' )" ];then rmmod nvidia 1>> $LOG_FILE 2>> $LOG_FILE fi rm -f /lib/modules/$KERNEL_VERSION/kernel/drivers/video/nvidia.*o 1>> $LOG_FILE 2>> $LOG_FILE rm -f /lib/modules/$KERNEL_VERSION/volatile/nvidia.*o >/dev/null 1>> $LOG_FILE 2>> $LOG_FILE # this is legacy stuff, not currently present rm -f /usr/local/bin/nvidia-settings /usr/local/bin/nvidia-xconfig 1>> $LOG_FILE 2>> $LOG_FILE rm -f /tmp/.X0-lock ## nvidia uninstallers, for systems where nvidia has been installed once at least # both files should be present in case of previous nvidia install if [ -x /usr/bin/$installer ];then log_function_data 'Using nvidia uninstaller: /usr/bin/'$installer /usr/bin/$installer --uninstall -s -N 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?" elif [ -f /usr/lib/libnvidia-tls.so.1 ];then log_function_data 'Using local nvidia uninstaller' # some cases this will not be present, like to native ati/nv conversion if [ -f ./$installer ];then ./$installer --uninstall -s -N 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?" fi fi if [ -n "$installError" ];then error_handler 192 $installError fi ## this is just to check after the above un-installer runs, this must be here or the ## above packages won't be present, better to let nvidia handle uninstalling itself # also can clean out install-binary-gfx packages or nvidia-glx if present oldNvidia=$( COLUMNS=200 dpkg -l | cut -d ' ' -f 3 | grep 'nvidia' ) if [ -n "$oldNvidia" ];then dpkg --purge $oldNvidia 1>> $LOG_FILE 2>> $LOG_FILE fi ####### FGLRX removal... # this is for manually installed amdccle removal rm -f /usr/local/bin/amdccle oldFglrx=$( COLUMNS=200 dpkg -l | cut -d ' ' -f 3 | grep 'fglrx' ) if [ -n "$oldFglrx" ];then dpkg --purge $oldFglrx 1>> $LOG_FILE 2>> $LOG_FILE fi # this is present in some installs, debian etch default for instance GL='/usr/X11R6/lib/libGL.so.1.2' for package in $( dpkg-divert --list | grep "diversion of $GL" | cut -d ' ' -f 7 | grep -v -e fglrx-driver -e xorg-driver-fglrx ) do dpkg-divert --package $package --remove $GL 1>> $LOG_FILE 2>> $LOG_FILE done eval $LOGPE } # arg: $1 - pre/post Undoing the patches in case the xen stuff is needed later # as of 2.6.25-2, debian kernels are compiled with xen, which breaks nvidia currently apply_module_patch() { eval $LOGPS local lmkv="/lib/modules/$KERNEL_VERSION" # the debian sid nvidia drivers are now working fine with xen enabled sid kernels if [ "$USE_DEBIAN_DRIVER" != 'true' ] && [ -d "$lmkv" -a -n "$IS_XEN" ];then # patch source: http://blog.creonfx.com/linux/how-to-install-nvidia-driver-on-2625-2-debian-kernel-with-xen cd $lmkv case $1 in pre) echo "${S}Running pre-install module patches (this might take a while)...${N}" grep 'CONFIG_XEN' . -Rl 2> /dev/null | xargs -i sed -i -e 's/CONFIG_XEN/CONFIG_LUPO/g' {} export IGNORE_XEN_PRESENCE=1 ;; post) echo "${S}Reverting pre-install module patches (this might take a while)...${N}" grep 'CONFIG_LUPO' . -Rl 2> /dev/null | xargs -i sed -i -e 's/CONFIG_LUPO/CONFIG_XEN/g' {} ;; esac cd $INSTALL_WORKING_DIR$INSTALL_DIRECTORY fi eval $LOGPE } ### run patch module, then install run_driver_installer() { eval $LOGPS local installError='' installerArgs='' local xModPath='/usr/lib/xorg/modules' local xLibPath='/usr/lib' local installer='nvidia-installer' local distroId='' local distroCodeName='' # this was set in prep_install() cd $INSTALL_WORKING_DIR$INSTALL_DIRECTORY echo "${S}Running driver installer for ${C}$DRIVER_DEFAULT${S} (this might take a while)...${N}" log_function_data "driver: $DRIVER_DEFAULT" # run the card installers case $CARD in $NVIDIA) if [ -d $xModPath -a -d $xLibPath ];then # --x-library-path=$xLibPath installerArgs="-s -N --x-module-path=$xModPath --x-library-path=$xLibPath" else installerArgs="-s -N" fi installerArgs="$installerArgs -k $KERNEL_VERSION" ./$installer $installerArgs 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?" # reverting the patched stuff before anything else happens apply_module_patch post ;; $FGLRX) distroId='Debian' distroCodeName='sid' installer='ati-installer.sh' installerArgs="$DRIVER_DEFAULT --buildpkg $distroId/$distroCodeName" log_function_data "dist-id/dist-codename: $distroId/$distroCodeName" # tell fglrx installer correct x version # if [ -n "$( echo $X_VERSION | egrep '[1-2]\.[4-9]' )" ] # then # export XVERSION=$X_VERSION # export XTYPE='X.Org' # fi LC_ALL= LC_CTYPE= LC_MESSAGES= LANG= bash ./$installer $installerArgs 1>> $LOG_FILE 2>> $LOG_FILE || installError="$?" ;; esac if [ -n "$installError" ];then error_handler 245 $installError fi case $CARD in $FGLRX) : ;; esac eval $LOGPE } post_installer_steps() { eval $LOGPS local ema='/etc/modutils/aliases' oldFglrx='' echo "${S}Running post installer steps...${N}" cd $INSTALL_WORKING_DIR rm -rf $INSTALL_DIRECTORY # remove the extracted driver install directory in /usr/src ## this I think I will combine into one, just cleanup everything, that will handle ## card brand changes more robustly, and leave less cruft in the system case $CARD in $NVIDIA) rm -f /etc/modutils/nvidia if [ -f $ema ];then perl -pi -e 's|.*char-major-195.*[\n]?||' $ema perl -pi -e 's|[\n]?$|\n|' $ema echo "alias char-major-195 nvidia" >> $ema fi ;; $FGLRX) clean_up_fglrx_junk rm -f fglrx-installer_*.changes ;; esac eval $LOGPE } ### ------------------------------------------------------------------- ### debian sid fglrx/nvidia driver installer ### ------------------------------------------------------------------- install_debian_drivers() { eval $LOGPS local nvidiaGlx='' nvidiaSource='' clean_up_fglrx_junk case $CARD in $NVIDIA) if [ "$LEGACY_LEVEL" -eq 1 ];then # nvidiaGlx='nvidia-glx-legacy' # nvidiaSource='nvidia-kernel-legacy-source' # if the two lines below don't work, comment them and uncomment the ones above nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_1" nvidiaSource="nvidia-kernel-legacy-$NV_DEBIAN_LEGACY_1-source" elif [ "$LEGACY_LEVEL" -eq 2 ];then nvidiaGlx="nvidia-glx-legacy-$NV_DEBIAN_LEGACY_2" nvidiaSource="nvidia-kernel-legacy-$NV_DEBIAN_LEGACY_2-source" else nvidiaGlx='nvidia-glx' nvidiaSource='nvidia-kernel-source' fi # start the install if [ "$LEGACY_LEVEL" -ne 0 ];then echo "${S}Installing ${C}$DEBIAN_NVIDIA${S} components...${N}" install_package nvidia-kernel-common install_package nvidia-settings install_package $nvidiaSource echo "${S}Creating ${C}$DEBIAN_NVIDIA${S} kernel module for kernel ${C}$KERNEL_VERSION${S}...${N}" # m-a --text-mode --non-inter -f -l ${KERNEL_VERSION} a-i $nvidiaSource m-a update 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 184 $DEBIAN_NVIDIA m-a prepare $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 185 $DEBIAN_NVIDIA m-a clean $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 182 $DEBIAN_NVIDIA m-a build -t -f -l $KERNEL_VERSION $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $DEBIAN_NVIDIA m-a install -t -f -l $KERNEL_VERSION $nvidiaSource 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $DEBIAN_NVIDIA #m-a prepare && m-a qa-i nvidia #nvidiaGlx has dependences problems. Workaround is to build-install the driver before install nvidiaglx echo "${S}Installing ${C}$nvidiaGlx${S} now...${N}" install_package $nvidiaGlx if [ -z "$( grep '^nvidia' /etc/modules )" ];then echo 'nvidia' >> /etc/modules fi fi ;; $FGLRX) echo "${S}Installing ${C}$DEBIAN_FGLRX${S} components...${N}" install_package fglrx-driver install_package fglrx-control # install_package fglrx-amdcccle install_package fglrx-kernel-src echo "${S}Creating ${C}$DEBIAN_FGLRX${S} kernel module for kernel ${C}$KERNEL_VERSION${S}...${N}" # damentz suggestion to make sure old module is used # m-a a-i -f fglrx-kernel-src # kelmo: m-a --text-mode --non-inter -f -l ${KERNEL_VERSION} a-i fglrx m-a update 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 184 $DEBIAN_FGLRX m-a prepare fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 185 $DEBIAN_FGLRX m-a clean fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 182 $DEBIAN_FGLRX m-a build -f -l $KERNEL_VERSION fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $DEBIAN_FGLRX m-a install -f -l $KERNEL_VERSION fglrx 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $DEBIAN_FGLRX ;; esac eval $LOGPE } ### ------------------------------------------------------------------- ### ATI fglrx specific stuff ### ------------------------------------------------------------------- clean_up_fglrx_junk() { eval $LOGUS rm -f /lib/modules/$KERNEL_VERSION/kernel/drivers/char/drm/fglrx.*o rm -f /lib/modules/$KERNEL_VERSION/volatile/fglrx.*o rm -rf /usr/src/modules/fglrx # this removes some config stuff that might cause watermarking issues rm -rf /etc/ati if [ -d /usr/lib/opengl ];then rm -rf /usr/lib/opengl ldconfig log_function_data 'Note: cleanup usr/lib/opengl' fi eval $LOGUE } # this is only for fgrlx install_fglrx_debs() { # ati change this syntax too much... hope they stabilize # fglrx-amdcccle_8.443.1-1_i386.deb # fglrx-driver_8.443.1-1_i386.deb # fglrx-driver-dev_8.443.1-1_i386.deb # fglrx-installer_8.443.1-1_i386.changes # fglrx-kernel-src_8.443.1-1_i386.deb if [ "$CARD" == $FGLRX ];then eval $LOGPS local fgAmd='fglrx-amdcccle_' fgDri='fglrx-driver_' fgKsc='fglrx-kernel-src_' local fgDriver="$fgDri$DRIVER_DEFAULT-1_*.deb" local fgAmdcccle="$fgAmd$DRIVER_DEFAULT-1_*.deb" local fgKernelSrc="$fgKsc$DRIVER_DEFAULT-1_*.deb" local availableDebs=$( ls *fglrx*.deb ) local fgKsrc='fglrx-kernel-src' local usunf='/usr/sbin/unfreeze-rc.d' frozen=0 forceIt='' # this is slightly excessive, but may handle a case where extra debs exist # due to weird user action. Also protects against new ati randomness. if [ -f $fgDriver ];then : elif [ -f $fgDri*.deb ];then fgDriver=$( ls $fgDri*.deb ) else error_handler 186 $fgDri fi if [ -f $fgKernelSrc ];then : elif [ -f $fgKsc*.deb ];then fgKernelSrc=$( ls $fgKsc*.deb ) else error_handler 186 $fgKsc fi if [ -f $fgAmdcccle ];then : elif [ -f $fgAmd*.deb ];then fgAmdcccle=$( ls $fgAmd*.deb ) else error_handler 186 $fgAmd fi if [ "$B_TESTING_1" == 'true' ];then forceIt='--force-all' fi log_function_data "These installation debs have been created: $availableDebs" echo "${S}Installing fglrx debs for kernel ${C}$KERNEL_VERSION${S}...${N}" # unfreeze/freeze stuff may be required for some legacy type systems if [ -f /etc/frozen-rc.d ];then frozen=1 fi if [ -x $usunf ];then $usunf fi # due to problems with config file questions, trying no logging of 1>> now dpkg -i $fgDriver 2>> $LOG_FILE || error_handler 195 $fgDriver dpkg -i $fgAmdcccle 2>> $LOG_FILE || error_handler 195 $fgAmdcccle dpkg -i $fgKernelSrc 2>> $LOG_FILE || error_handler 195 $fgKernelSrc CC=$CC m-a build -l $KERNEL_VERSION -f $fgKsrc 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 194 $fgKsrc m-a install -l $KERNEL_VERSION -f $fgKsrc 1>> $LOG_FILE 2>> $LOG_FILE || error_handler 193 $fgKsrc # restore freeze state if [ "$frozen" -eq 1 -a -x $usunf ];then $usunf fi # put packages on hold fglrx-amdcccle, fglrx-driver, fglrx module echo "${S}Placing ATI packages on hold to avoid dist-upgrade issues with Debian fglrx drivers...${N}" echo fglrx-amdcccle hold | dpkg --set-selections echo fglrx-driver hold | dpkg --set-selections eval $LOGPE fi } ### ------------------------------------------------------------------- ### Finalizing steps ### ------------------------------------------------------------------- final_install_steps() { eval $LOGPS local emod='/etc/modules' fgModules='radeon drm fglrx' fgModule='' echo "${S}Finalizing install...${N}" process_xvmc depmod $KERNEL_VERSION -a # Probe all modules case $CARD in $NVIDIA) # this needs to be cleaned up a bit mkdir -p /etc/udev/rules.d rm -f /etc/udev/nvidia.rules /etc/udev/rules.d/nvidia.rules ldconfig # Configure Dynamic Linker Run Time Bindings. ;; $FGLRX) ## clean up install parts rm -rf /usr/src/modules/fglrx rm -f /tmp/fglrx* fglrx* dpkg --purge fglrx-kernel-src 1>> $LOG_FILE 2>> $LOG_FILE # test for, then remove if present for fgModule in $fgModules do if [ -n "$( lsmod | cut -d ' ' -f 1 | grep "$fgModule" )" ];then rmmod $fgModule 1>> $LOG_FILE 2>> $LOG_FILE fi done perl -pi -e 's/^[\s]*radeon/#radeon/' $emod perl -pi -e 's/^[\s]*fglrx/#fglrx/' $emod ;; esac sync # Force changed blocks to disk, update the super block echo ${M}$LINE echo "${S}Congratulations! It looks like your new ${C}$DRIVER_DEFAULT $CARD${S} driver installed successfully!${N}" eval $LOGPE } process_xvmc() { eval $LOGUS local lxvmcN='libXvMCNVIDIA_dynamic.so.1' lxvmc='libXvMC.so.1' exxv='/etc/X11/XvMCConfig' # xvmc information here: http://www.mythtv.org/wiki/index.php/XvMC if [ "$USE_XVMC" == 'true' -a "$NO_XMVC" != 'true' -a -x /usr/lib/$lxvmcN ];then echo $lxvmcN > $exxv else echo $lxvmc > $exxv fi eval $LOGUE } ### ------------------------------------------------------------------- ### Stop / Start Xorg handling section ### ------------------------------------------------------------------- x_start_stop_master() { eval $LOGPS case $1 in stop) if [ "$B_SKIP_FUNCTION" != 'true' -a "$SM_INSTALL" != 'true' -a "$SKIP_X_TEST" != 'true' -a "$AUTORUN" != 'true' ];then start_stop_x stop fi ;; start) if [ "$AUTORUN" != 'true' ];then if [ "$SKIP_X_QUESTION" == 'true' ];then start_stop_x start else # no point in starting x unless required if [ -z "$DISPLAY" ];then start_x_question # handles case where sgfxi is run in X else echo "${S}All done with driver install. Remember, you have to restart X for the new" echo "driver you installed to be active (ctrl+backspace).${N}" fi fi fi ;; esac eval $LOGPE } start_x_question() { eval $LOGPS local opt='' options='' repeat='' package='' local ia32libs='ia32-libs' iaOpt='install-ia32libs' local ia32Alert='echo -e "\n${M}You should probably (re)install ${C}$ia32libs${M} (even if already installed)\nif you use applications that depend on them in your ${C}64 bit${M} system,\nfor example ${C}Wine${M}.${N}"' local ia32Install='echo -e "${C}$iaOpt${M} - Install ${C}$ia32libs${M} libs."' local fgGlxOpt='' fgGlx='' fgGlxAlert='' fgGlxInstall='' local startXReboot='start-x' startXRebootText='All finished, (re-)start X/kde now.' case $BITS in 32) ia32Alert='' ia32Install='' iaOpt='' ;; 64) case $CARD in $FGLRX) fgGlxOpt='install-fglrx-glx' fgGlx='fglrx-glx fglrx-glx-ia32' fgGlxAlert='echo -e "\n${M}You might want to (re)install ${C}$fgGlx${M} (even if already installed)\nif you have problems with your ${C}64 bit ATI/fglrx${M} driver/apps.${N}"' fgGlxInstall='echo -e "${C}$fgGlxOpt${M} - Install ${C}$fgGlx${M}."' ;; $NVIDIA) : ;; esac ;; esac if [ -n "$INSTALL_TO_KERNEL" -a "$INSTALL_TO_KERNEL" != "$( uname -r )" ];then startXReboot='reboot-now' startXRebootText='You must reboot before you can continue into X.' fi echo ${M}$LINE echo "${S}Your driver install is now finished. You have the following options:" eval $ia32Alert eval $fgGlxAlert echo $LINE eval $ia32Install eval $fgGlxInstall echo "${C}$startXReboot${M} - $startXRebootText" echo "${C}quit${M} - Quit now, to do something else before starting X.${N}" echo $LINE options="$iaOpt $fgGlxOpt $startXReboot quit" select opt in $options do case $opt in install-ia32libs) if [ "$BITS" == '64' ];then echo "${S}Installing the package ${C}$ia32libs${S} now...${N}" install_package $ia32libs '' '--reinstall' log_function_data "Final Step: Installed: $ia32libs" else echo "${E}The package ${C}$ia32libs${E} is only available for ${C}64 bit${E} systems.${N}" fi # repeat the question for users so they can start x now if they want. repeat='true' ;; install-fglrx-glx) if [ "$BITS" == '64' -a "$CARD" == $FGLRX ];then echo "${S}Installing packages ${C}$fgGlx${S} now...${N}" for package in $fgGlx do install_package $package '' '--reinstall' done log_function_data "Final Step: Installed: $fgGlx" else echo "${E}The packages ${C}$fgGlx${E} are only installable in ${C}64 bit + ATI fglrx${E} systems.${N}" fi # repeat the question for users so they can start x now if they want. repeat='true' ;; start-x) echo "${S}Ok, starting X now, thanks for using this script.${N}" log_function_data "Final Step: start-x" start_stop_x start ;; reboot-now) echo "${S}Ok, rebooting into kernel ${C}$INSTALL_TO_KERNEL${S} and your" echo "${C}$DRIVER_DEFAULT${S} video driver. Thanks for using this script.${N}" log_function_data "Final Step: reboot to kernel: $INSTALL_TO_KERNEL" reboot exit 100 # need to exit with 100 to not trigger root pid kill in smxi ;; quit) echo "${S}Ok, exiting now, thanks for using this script.${N}" # this is to send calling script message that it should not do its success action log_function_data "Final Step: quit" exit 100 # need to exit with 100 to not trigger pid root kill in smxi ;; *) echo "${W}Please select one of the options in the list, thank you.${N}" repeat='true' ;; esac break done if [ "$repeat" == 'true' ];then start_x_question fi eval $LOGPE } # start_x_question # takes one argument, stop or start start_stop_x() { eval $LOGUS local displayManagers='entrance gdm kdm slim wdm xdm' dman='' success='' # setting the default will handle cases like default 2 while still handling 3/5 local defaultRunlevel=$( grep ':initdefault:' /etc/inittab | egrep -o '[0-5]' ) ### restart x if this is not being run by smxi if [ -z "$DISPLAY_MANAGER" ];then for dman in $displayManagers do if [ -x /etc/init.d/$dman ];then # nohup is required to make sure dm is fully stopped, and pids removed nohup /etc/init.d/$dman $1 2>/dev/null && success='true' fi done else if [ -x /etc/init.d/$DISPLAY_MANAGER ];then # I tried stringing these in a && sequence but something failed and # init 5 start broke. This order takes care of runlevel restart bug # nohup is required to make sure dm is fully stopped, and pids removed nohup /etc/init.d/$DISPLAY_MANAGER $1 && success='true' fi fi # this handles cases where somehow X is still running # startx x starts can for example bypass kdm tests, etc if [ "$1" == 'stop' ];then if [ "$( x_is_running )" -eq 0 ];then echo "${M}Note: display manager shutdown failed... shutting down X directly instead...${N}" nohup killall Xorg fi fi # this will exit the root shell on successful run of start x if [ "$1" == 'start' -a "$success" == 'true' ];then if [ "$SM_INSTALL" != 'true' ];then # the failure case handels a weird thing when kill gives error if [ -n "$LOGIN_PID" ];then init $defaultRunlevel && kill $LOGIN_PID && exit 0 || exit 1 else echo "${E}No login Pid found to kill, starting init 5 and leaving your root logged in.${N}" init $defaultRunlevel && exit 0 || exit 1 fi else exit 0 # smxi will handle the pid root kill fi fi eval $LOGUE } x_is_running() { eval $LOGUS # we'll do one final X is running test here, note, handling a bunch of # different possible X detections in etch, lenny, and sid, then filtering out the grep local xIsRunning=$( ps aux | grep '/usr.*/X' | grep -vc 'grep' ) if [ "$xIsRunning" -gt 0 ];then echo 0 else echo 1 fi eval $LOGUE } ######################################################################## #### xorg configuration (previously in sgfxi-lib-xorg) #### ------------------------------------------------------------------- # create required section device: create_section_device() { eval $LOGUS # if this section is not present, create it if [ "$( egrep -ic 'Section[ \t]*"Device"' $EXXC )" -eq 0 ];then echo >> $EXXC echo -e 'Section "Device"' >> $EXXC echo -e '\tIdentifier "Card0"' >> $EXXC # the vesa is a just a failsafe, the actual driver will be set in driver version # echo -e '\tDriver "vesa"' >> $EXXC # echo -e '\tBusID "PCI:'$BUS_ID'"' >> $EXXC echo 'EndSection' >> $EXXC echo >> $EXXC fi # now fill it if needed eval $LOGUE create_driver_entry } # some rough code, will write driver / pciid if required,this is mainly for systems # that are using the new xorg, and may not have a driver/busid entry. # if all goes well, will only create a driver / busid entry if missing create_driver_entry() { eval $LOGUS # since this is set in the above function, it must exist, but I'll check to make sure local deviceLineNu=$( egrep -in 'Section[[:space:]]*"Device"' $EXXC | cut -d ':' -f 1 ) # echo deviceLineNu: $deviceLineNu # make sure it's numeric, and that only one device section number was returned (space) if [ -n "$( egrep '^[0-9]+$' <<< $deviceLineNu )" ];then # this is a trick to only grep within a block delimited by start/EndSection local isDriver=$( sed -n ''$deviceLineNu',/EndSection/ p' $EXXC | egrep -i 'Driver[[:space:]]*".*"' ) local isBusId=$( sed -n ''$deviceLineNu',/EndSection/ p' $EXXC | egrep -i 'BusID[[:space:]]*".*"' ) # echo isBusId: $isBusId # echo isDriver: $isDriver # the vesa is a just a failsafe, the actual driver will be set in driver version # this logic is complicated but seems to work, check the range in section device # line number to EndSection, then update the driver and busid if needed, as per # tests above already done # I'm not sure why -r didn't work, but it didn't in this case. if [ -z "$isDriver" ];then sed -i ''${deviceLineNu}',/EndSection/ s/Section[[:space:]]*"Device"/&\ \tDriver "vesa"/' $EXXC fi # only adding busid if driver is missing, otherwise mistakes will happen # xorg has a bug with bus id with hex, this is now handled in sgfxi # commented unless required by dual card presence, then uncommented if [ -z "$isBusId" ];then pcibusid_hex_to_dec sed -i ''${deviceLineNu}',/EndSection/ s/Driver[[:space:]]".*"/&\ \t#BusID "PCI:'${BUS_ID}'"/' $EXXC fi fi eval $LOGUE } # this will reset any hex in bus id string to avoid that new xorg failure to handle hex pcibusid_hex_to_dec() { eval $LOGUS local pt1=$( cut -d ':' -f 1 <<< $BUS_ID ) local pt2=$( cut -d ':' -f 2 <<< $BUS_ID ) local pt3=$( cut -d ':' -f 3 <<< $BUS_ID ) local tempPt1='' tempPt2='' tempPt3='' let tempPt1=0x$pt1 let tempPt2=0x$pt2 let tempPt3=0x$pt3 BUS_ID="$tempPt1:$tempPt2:$tempPt3" eval $LOGUE } # this will handle cases where user is changing from one card to another update_xorgconf_driver_version() { eval $LOGUS local driverName=$CARD if [ "$NATIVE_DRIVER" == 'true' ];then case $CARD in $FGLRX) driverName='ati' ;; $INTEL) driverName='intel' ;; $NEOMAGIC) driverName='neomagic' ;; $NVIDIA) driverName='nv' ;; $TDFX) driverName='tdfx' ;; esac # this handles hard overrides to specific driver if [ -n "$NATIVE_OVERRIDE" ];then driverName=$NATIVE_OVERRIDE fi fi # not converting: i810-modesetting i740 i128: note openchrome just released in sid # previous: (i810|nvidia|nv|fglrx|ati|radeon|apm|iftv|fbdev|vesa) # these are all current xserver-xorg-video-xxxx drivers, plus nvidia and fglrx sed -i -r 's%^\s*Driver\s*"(apm|ark|ati|chips|cirrus|cyrix|fbdev|fglrx|glint|iftv|ivtv|i810|imstt|intel|mesa|mga|neomagic|newport|nsc|nv|nvidia|openchrome|radeon|radeonhd|rendition|s3|s3virge|savage|siliconmotion|sis|tdfx|tga|trident|tseng|v4l|vesa|vga|via|vmware|voodoo)"%\tDriver\t"'$driverName'"%' $EXXC eval $LOGUE } # if required, create the Extensions section, then set it to what is needed for # each specific argument/driver combination check_extensions() { eval $LOGUS local stateOn=1 stateOff=0 # default for nvidia local turnOff='' rendState=0 compState=0 aiglxString='' local compComment='#' rendComment='#' # for composite to be active, fglrx composite must be set to 0, not 1 case $CARD in $FGLRX) #stateOn='Enable' # check into enable/disable syntax for fglrx/ati/radeon here #stateOff='Disable' stateOn='1' stateOff='0' compState=$stateOff rendState=$stateOff # this stuff needs to be Disabled explicitly, no comments for fglrx only. if [ "$NATIVE_DRIVER" != 'true' ];then rendComment='#' compComment='' #aiglxString='\n\tOption\t"AIGLX"\t"'$stateOff'"' fi ;; $NVIDIA|$INTEL) if [ "$COMPOSITE" == 'true' ];then compState=$stateOn compComment='' else compState=$stateOff fi ;; esac # clear out all previous extension stuff: note: fglrx composite, aiglx, render: off perl -pi -e 's/^[\s]*#*[\s]*Option\s*"COMPOSITE".*\n?//; s/^[\s]*#*[\s]*Option\s*"Composite".*\n?//; s/^[\s]*#*[\s]*Option\s*"RENDER".*\n?//; s/^[\s]*#*[\s]*Option\s*"Render".*\n?//; s/^[\s]*#*[\s]*Option\s*"AIGLX".*\n?//; s/^[\s]*#*[\s]*Option\s*"Aiglx".*\n?//' $EXXC # if this section is not present, create it if [ "$( grep -c 'Extensions' $EXXC )" -eq 0 ];then echo -e '\nSection "Extensions"' >> $EXXC echo 'EndSection' >> $EXXC fi # rebuild the extensions now perl -pi -e 's/^([\s]*Section\s*"Extensions")/\1\n'$compComment'\tOption "Composite"\t"'$compState'"\n'$rendComment'\tOption "RENDER"\t"'$rendState'"'$aiglxString'/' $EXXC eval $LOGUE } # resets xorg to basics, strips out all fglrx/nvidia specific stuff clear_prep_xorg() { eval $LOGUS perl -pi -e 's/^[\s]*Load\s*"GLcore"/#\tLoad\t"GLcore"/; s/^[\s]*Load\s*"dri"/#\tLoad\t"dri"/; s/^[\s]*#*[\s]*Load\s*"glx"/\tLoad\t"glx"/; s/^.*Load\s*"speedo".*\n?//; s/DefaultColorDepth.*/DefaultColorDepth 24/; s/^[\s]*Option\s*"sw_cursor"/\t#Option "sw_cursor"/; s/^[\s]*#*[\s]*Option\s*"Composite".*/#\tOption\t"Composite"\t"1"/; s/^.*UseInternalAGPGART.*\n?//; s/^.*VideoOverlay.*\n?//; s/^.*OpenGLOverlay.*\n?//; s/^.*MonitorLayout.*\n?//; s/^.*IgnoreDisplayDevices.*\n?//; s/^.*Coolbits.*\n?//; s/^.*RenderAccel.*\n?//; s/^.*AllowGLXWithComposite.*\n?//; s/^.*RandRRotation.*\n?//; s/^.*AddARGBGLXVisuals.*\n?//; s/^.*DisableGLXRootClipping.*\n?//; s/^.*TripleBuffer.*\n?//; s/^.*UseEDID.*\n?//; s/^.*UseEdidFreqs.*\n?//; s/^.*DynamicTwinView.*\n?//; s/^.*AGPFastWrite.*\n?//; s/^.*AGPMode.*\n?//; s/^.*DynamicClocks.*\n?//; s/^.*ColorTiling.*\n?//; s/^.*EnablePageFlip.*\n?//; s/^.*TexturedXrender.*\n?//; s/^.*AccelMethod.*\n?//' $EXXC # turn on dri again for fglrx/intel, it's off for nvidia case $CARD in $FGLRX|$INTEL) perl -pi -e 's/^[\s]*#*[\s]*Load\s*"dri"/\tLoad\t"dri"/' $EXXC ;; esac eval $LOGUE } remove_modelines() { eval $LOGUS local removeThem='' ### this handles standard cases, always for fglrx, never for native ati/nv # and whenever required by argument. I'll see if native ever needs them removed if [ "$CARD" == $FGLRX -o "$REMOVE_MODELINES" == 'true' ];then if [ "$NATIVE_DRIVER" == 'true' -a "$REMOVE_MODELINES" == 'true' ];then removeThem='true' elif [ "$NATIVE_DRIVER" != 'true' ];then removeThem='true' fi fi if [ "$removeThem" == 'true' ];then perl -pi -e 's/^.*Mode.ine.*\n?//g' $EXXC fi eval $LOGUE } update_xorg() { eval $LOGPS # this to second time stamp should help fix that old repeated .1st bug local timeStampXorg=$EXXC-bu-$( date +%Y-%m-%d-%H:%M:%S ) local stateOn='1' stateOff='0' # nvidia stuff local rend=$stateOn twin=$stateOn triple=$stateOff # note: putting a space in these subsitution patterns breaks perl -e local ignoreDisplay='Option\t"IgnoreDisplayDevices"\t"TV"\n\t' # fglrx stuff, we're using default agpart no now instead local agpart='no' layout='AUTO,AUTO' allowGlx='' # this is set in rare cases of dual card early copy of xorg.conf if [ "$XORG_BACKED_UP" != 'true' ];then if [ ! -e $timeStampXorg ];then cp $EXXC $timeStampXorg fi log_function_data "xorg.conf was backed up to: $timeStampXorg" echo "${S}Backup copy of your previous version: ${C}$timeStampXorg${N}" fi echo "${S}Updating your ${C}$EXXC${S} file now...${N}" create_section_device # create section "device" if missing update_xorgconf_driver_version # will set to correct version clear_prep_xorg # bring xorg.conf to default condition check_extensions remove_modelines if [ "$NATIVE_DRIVER" != 'true' ];then case $CARD in $NVIDIA) # set any custom stuff here #[ "$RENDER_ACCEL" != 'true' ] && rend=$stateOff if [ "$DISPLAY_DEVICES" == 'true' ];then ignoreDisplay='' fi # this is legacy, new default is on #[ "$TWINVIEW" == 'true' ] && twin=$stateOn # triplebuffer can reduce 3d performance on cards with low graphics memory # 64 mb or less. Default is off/disable/0 if [ "$TRIPLE_BUFFER" == 'true' ];then triple=$stateOn fi # this should let 3D work again for older cards, 400 etc if [ "$DRIVER_DEFAULT" == "$NV_LEGACY_1" ];then allowGlx='Option\t"AllowGLXWithComposite"\t"1"\n\t' fi perl -pi -e 's/^([\s]*Driver\s*"nvidia")/\1\n\t'$ignoreDisplay$allowGlx'Option "Coolbits"\t"1"\n\tOption "RandRRotation"\t"1"\n\tOption "AddARGBGLXVisuals"\t"1"\n\tOption "TripleBuffer"\t"'$triple'"\n\tOption "DynamicTwinView"\t"'$twin'"/' $EXXC ;; $FGLRX) # set any custom stuff here # only use fglrx internal agpart if not in system and never for 64 bit #[ "$( lsmod | grep -c 'agpgart' )" -gt 0 -o "$BITS" == '64' ] && agpart='no' # this is only for laptops # if [ -n "$(find /proc/acpi/battery/ -mindepth 1 -type d 2>/dev/null)" ] # then # layout='LVDS,AUTO' # no space in string # fi # \n\tOption "UseInternalAGPGART" "'$agpart'"\n\tOption "VideoOverlay" "on" # \n\tOption "MonitorLayout" "'$layout' perl -pi -e 's/^([\s]*Load\s*"extmod")/#\1\n\tSubSection "extmod"\n\t Option "omit xfree86-dga"\n\tEndSubSection/; s/^([\s]*Driver\s*"fglrx")/\1\n\tOption "UseInternalAGPGART" "'$agpart'"\n\tOption "TexturedXrender"/' $EXXC ;; esac ### Native ati/nv specific stuff else if [ "$CARD" == $INTEL ];then : elif [ "$NATIVE_OVERRIDE" == 'radeon' ];then perl -pi -e 's/^([\s]*Driver\s*"radeon")/\1\n\tOption "AGPFastWrite" "off"\n\tOption "AGPMode" "4"\n\tOption "ColorTiling" "on"\n\tOption "DynamicClocks" "on"\n\tOption "EnablePageFlip" "on"\n\tOption "AccelMethod" "XAA"/' $EXXC fi fi eval $LOGPE } ######################################################################## #### OPTIONS ######################################################################## # keep this above getopts to keep it readable # args: $1 if err or not, $2 extra data show_options() { local xVersion=$X_VERSION if [ -z $X_VERSION ];then xVersion="${W}NO SUPPORTED XORG!${N}" fi #local pattern='(1\.0-)?([0-9]{4}|1[0-9]{2}\.[0-9]{2}\.?[0-9]{0,2}):?' #local nvDefault=$( echo $NV_DEFAULT | sed -r 's/'$pattern'/\2 /g') local nvDefault=$( echo $NV_DEFAULT | tr ':' ' ' | sed 's/1.0-//g' ) #local nvVersions=$( echo "$NV_VERSIONS:$NV_OTHERS" | sed -r 's/'$pattern'/\2 /g') local nvVersions=$( echo "$NV_VERSIONS:$NV_OTHERS" | tr ':' ' ' | sed 's/1.0-//g') #local nvQuadText='' nvQuad=$( echo $NV_QUAD | sed -r 's/'$pattern'/\2 /g') local nvQuadText='' nvQuad=$( echo $NV_QUAD | tr ':' ' ' | sed 's/1.0-//g') local fgDefault=$FG_DEFAULT local fgVersions=$( echo "$FG_VERSIONS:$FG_OTHERS" | sed 's/:/ /g') local nativeVersions=$( echo $NATIVE_OVERRIDE_SUPPORTED | sed 's/|/ /g' ) local fgTesting='' nvTesting='' testingText='' fgDebianSid='' if [ "$DEBIAN_FLAG" == 'true' ];then fgDebianSid='echo -e "'${W}'ATI: installer package '$fgDefault' is currently BROKEN. Script will default to: '$DEBIAN_FGLRX${N}'"' else fgDebianSid='echo -e "fglrx: default: '$fgDefault' supported-drivers: '$fgVersions'"' fi if [ -n "$NV_TESTING" -a "$NV_TESTING" != "$NV_DEFAULT" ];then nvTesting='echo -e "nvidia:\t'$( echo $NV_TESTING | tr ':' ' ' )'"' fi if [ -n "$FG_TESTING" -a "$FG_TESTING" != "$FG_DEFAULT" ];then fgTesting='echo -e "fgrlx:\t'$FG_TESTING'"' fi if [ -n "$fgTesting" -o -n "$nvTesting" ];then testingText='echo "The following drivers are available for testing purposes:"' fi if [ -n "$NV_QUAD" -a "$NV_QUAD" != "$NV_DEFAULT" ];then nvQuadText='echo -e "Nvidia Quadroplex driver (automatically selected if you have a Quad card): '$nvQuad'"' fi if [ "$1" == 'err' ];then echo "${W}Sorry, one of your arguments is not a supported option.${N}" echo "Please check the following options and try again." echo $LINE fi if [ -n "$DISPLAY" ];then echo "${W}While you can run this script in X, we recommend you run it in terminal.${N}" echo $LINE fi echo "Script Requirements: Only true Debian based systems. No *buntus." echo "Xorg version required: 7.1/1.1 or greater - Your X version: $xVersion" echo "Linux Kernel required: 2.6.18 or greater - Your kernel: $(uname -r)" echo $LINE echo "'default:' - This is the driver installed automatically unless it is not supported by" echo "your card. Some older cards will force an override of this basic default. Script will" echo "print out what driver it will install when you start it up, with option to exit." echo echo "'supported-drivers:' choices require -o to install." eval $fgDebianSid #echo "fglrx: default: $fgDefault supported-drivers: $fgVersions" echo "nvidia: default: $nvDefault supported-drivers: $nvVersions" eval $nvQuadText eval $testingText eval $nvTesting eval $fgTesting echo $LINE echo "These are your supported options:" echo "-A Run the install non-interactively. Will not restart x at end." echo "-b Enable tripleBuffer (nvidia only). triplebuffer can reduce 3d performance on cards" echo " with low graphics memory (64 mB or less). Default is disabled/off." echo "-c Use composite mode. For things like Beryl/Compiz (nVidia cards only)." echo "-C Skip Xorg configuration. Only use this if your Xorg is already working with your driver." echo " Main use is if you have dual card output and don't want xorg.conf changed." echo "-d Remove IgnoreDisplayDevices, allow TV for example (nVidia cards only)." # leaving these commented out in case new experimental xorg drivers need to be tested # echo "-e Use experimental drivers (currently: xorg ati only)." # echo "-E Adds extra experimental driver features. Currently libdrm2 things for ati." echo "-h View this help menu." echo "-j Alternate text/output script colors. Requires this syntax: -j 0 (sets to monochrome )" echo " -j 1 (script default); -j 2 (alternate color scheme); -j 3 (nice earthy scheme)" echo "-K Installs nVidia/fglrx driver for another kernel. Syntax: sgfxi -K 2.6.25-2" echo " $SCRIPT_NAME will double check that the kernel exists." echo "-n Automatically installs correct native xorg nv, intel, or ati driver for your system." echo " Cleans up old binary driver stuff, updates xorg.conf with new driver information," echo " and cleans nvidia and fgrlx stuff out of xorg.conf" echo "-N Force install of specific xorg driver. Syntax: $SCRIPT_NAME -N " echo " Supported Xorg drivers: $nativeVersions" echo " Also configures xorg.conf as required. Full radeon xorg 3d configuration automatically." echo "-o Override default: install a specific driver, this is an absolute override - syntax:" echo " -o 177.68 (for nVidia) or: -o 8-6 (for fglrx)" # echo "-p Print currently supported drivers, :::" # echo " then exit the script without doing the driver download/install." echo "-Q Skip start X Question, automatically start X post driver install." echo "-r Remove mode lines from xorg.conf" echo "-t Enables dynamic twinview (nVidia only) - LEGACY, unused now. Default is on, enabled." echo "-R Skips self updating feature. No restart." echo "-s Installs Debian nVidia/fglrx drivers. ATI/nVidia cards only." echo "-S Skips automatic logout and X startup when script is run in standalone mode." echo "-U Forces $SCRIPT_NAME to update itself, must be root, but can be in x. Exits after." echo "-v Prints $SCRIPT_NAME current version information. Exits after." echo "-W Skip all wget downloads and connection tests. Only use this to reinstall a driver" echo " that has already been downloaded using $SCRIPT_NAME at least once previously." echo "-x Reverts to default libXvMC.so.1 for system instead of nVidia package (nVidia only)" echo "-X Use to skip auto X start/stop. Do not use this unless you have a good reason to not " echo " want X start/stop tests to run. Gives start X option on completion if not in X." echo "-Z Skips connection test. Use this if $SCRIPT_NAME gives you connection failed error but" echo " you are sure your connection is fine." if [ "$1" == 'full' ];then echo "" echo "Developer and Testing Options (Advanced):" echo "-! 1 - Sets flag B_TESTING_1='true' to trigger testing condition 1." echo "-! 2 - Sets flag B_TESTING_2='true' to trigger testing condition 2." echo "-! 3 - Sets flag B_SKIP_FUNCTION='true' to turn off some functions." echo "-! 4 - Sets flags B_TESTING_1='true' and B_TESTING_2='true'." echo "-! 5 - Sets flags B_TESTING_1='true' and B_SKIP_FUNCTION='true'." echo "-! 10 - Triggers an update from the primary dev download server." echo "-! 11 - Triggers an update from svn branch one - if present, of course." echo "-! 12 - Triggers an update from svn branch two - if present, of course." echo "-! - Triggers an update from whatever server you list." echo "-! 20 - Uses patch from svn branch one server (must be in branch/one/patches)." echo "-! 21 - Uses patch from svn branch two server (must be in branch/two/patches)." fi echo if [ "$1" == 'err' ];then exit 1 else exit 0 fi } # args: $1 - "$@" get_options() { local opt='' while getopts AbcCdDeEhHj:K:nN:o:pP:QrRsStUvWXxZ!: opt do case $opt in A) AUTORUN='true' START_OPTIONS=$START_OPTIONS' -A' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -A - Autorun is selected\n" ;; b) TRIPLE_BUFFER='true' START_OPTIONS=$START_OPTIONS' -b' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -b - TripleBuffer is on (nVidia only)\n" ;; c) COMPOSITE='true' START_OPTIONS=$START_OPTIONS' -c' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -c - Composite is on. Does not work with legacy nVidia driver (nVidia|Intel only)\n" ;; C) SKIP_CONFIG='true' START_OPTIONS=$START_OPTIONS' -C' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -C - Xorg.conf will not be modified by this script.\n" ;; d) DISPLAY_DEVICES='true' START_OPTIONS=$START_OPTIONS' -d' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -d - IgnoreDisplayDevices is off. TV will be used. nVidia only.\n" ;; D) SM_INSTALL='true' S=${CALLER_DEF} # change standard text color to caller standard text START_OPTIONS=$START_OPTIONS' -D' ;; # e) EXPERIMENTAL='true' # START_OPTIONS=$START_OPTIONS' -e' # ;; # E) EXTRA_EXPERIMENTAL='true' # START_OPTIONS=$START_OPTIONS' -E' # ;; j) if [ -n "$( egrep '^[0-3]$' <<< $OPTARG )" ];then SCRIPT_COLORS=$OPTARG START_OPTIONS=$START_OPTIONS" -j $OPTARG" # no reason to reset the colors if they are default if [ "$SCRIPT_COLORS" != 1 ];then START_OPTIONS=$START_OPTIONS" -j $SCRIPT_COLORS" set_script_colors fi else error_handler 228 $OPTARG fi ;; K) INSTALL_TO_KERNEL="$OPTARG" START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -K - You are installing a graphic driver onto the kernel: ${C}$INSTALL_TO_KERNEL${S}\n" test_install_kernel_version START_OPTIONS=$START_OPTIONS" -K $OPTARG" ;; n) NATIVE_DRIVER='true' START_OPTIONS=$START_OPTIONS' -n' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -n - Auto install of native xorg intel, nvidia, 3dfx, or ati drivers.\n" ;; N) if [ -n $( egrep '('$NATIVE_OVERRIDE_SUPPORTED')' <<< $NATIVE_OVERRIDE ) ];then NATIVE_OVERRIDE="$OPTARG" NATIVE_DRIVER='true' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -N - Native driver custom install. You have requested to install the xorg driver: $NATIVE_OVERRIDE\n" START_OPTIONS=$START_OPTIONS" -N $OPTARG" else error_handler 237 $NATIVE_OVERRIDE fi ;; o) DRIVER_OVERRIDE="$OPTARG" START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -o - Driver override. Forces install of this driver: $DRIVER_OVERRIDE (nVidia|ATI fglrx only)\n" START_OPTIONS=$START_OPTIONS" -o $OPTARG" ;; p) PRINT_VER='true' START_OPTIONS=$START_OPTIONS' -p' ;; P) if [ -n $( egrep '^(apt-get|aptitude)$' <<< $OPTARG ) ];then PACKAGE_MANAGER=$OPTARG APT_TYPE=$OPTARG START_OPTIONS=$START_OPTIONS" -P $OPTARG" else error_handler 228 $OPTARG fi ;; Q) SKIP_X_QUESTION='true' START_OPTIONS=$START_OPTIONS' -Q' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -Q - X will start automatically when the driver install is finished.\n" ;; r) REMOVE_MODELINES='true' START_OPTIONS=$START_OPTIONS' -r' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -r - Remove modelines in xorg.conf (ATI only).\n" ;; R) SKIP_RESTART='true' ;; s) USE_DEBIAN_DRIVER='true' START_OPTIONS=$START_OPTIONS' -s' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -s - Install Debian driver. (ATI fglrx or nVidia)\n" ;; S) SKIP_AUTOSTART='true' START_OPTIONS=$START_OPTIONS' -S' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -S - Skip autostart of X/kde.\n" ;; t) TWINVIEW='true' START_OPTIONS=$START_OPTIONS' -t' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -t - twinview on: this is deprecated. Always sets for twinview (nVidia only)\n" ;; U) FORCE_UPDATE='true' ;; v) print_information exit 0 ;; W) SKIP_WGET='true' START_OPTIONS=$START_OPTIONS' -W' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -W - Skip wget connection tests. Only use if you are having problems connecting but connection is fine.\n" ;; x) NO_XVMC='true' # because two flags are required to use nvidia xvmc, this is fine START_OPTIONS=$START_OPTIONS' -x' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -x - Skip nVidia xvmc setup. (nVidia only)\n" ;; X) SKIP_X_TEST='true' START_OPTIONS=$START_OPTIONS' -X' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -X - Skip the test for X/KDE. Only use if you know what you are doing!\n" ;; Z) SKIP_CONNECT='true' START_OPTIONS=$START_OPTIONS' -Z' START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -Z - Skip the script connection tests. Limited utility, unless you already have downloaded the driver.\n" ;; h) show_options ;; H) show_options 'full' ;; ## debuggers and testing options !) # test for various supported methods case $OPTARG in 1) B_TESTING_1='true' ;; 2) B_TESTING_2='true' ;; 3) B_SKIP_FUNCTION='true' ;; 4) B_TESTING_1='true' B_TESTING_2='true' ;; 5) B_TESTING_1='true' B_SKIP_FUNCTION='true' ;; 10) check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_DEV" 'dev server' ;; 11) check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server' ;; 12) check_update_script "$SCRIPT_NAME" "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server' ;; http*) check_update_script "$SCRIPT_NAME" "$OPTARG" 'alt server' ;; 20) PATCH_DOWNLOAD="$SCRIPT_DOWNLOAD_BRANCH_1" ;; 21) PATCH_DOWNLOAD="$SCRIPT_DOWNLOAD_BRANCH_2" ;; *) error_handler 178 "$OPTARG" ;; esac START_OPTIONS="$START_OPTIONS -! $OPTARG" START_OPTIONS_PRINT=$START_OPTIONS_PRINT" -! $OPTARG - You are using an advanced Testing option. Only use this if you know what you are doing!\n" ;; *) show_options err ;; esac done #in case -n is used too - note: this will never be true, have to fix this one if [ "$NATIVE_DRIVER" == "true" -a -n "$INSTALL_TO_KERNEL" ];then echo "${W}WARNING: -n will uninstall binary drivers to all the kernels, not just $KERNEL_VERSION${N}" fi } ######################################################################## #### EXECUTE ######################################################################## # this must be set before anything else runs in script, -j will reset to no colors set_script_colors $COLOR_DEFAULT # set all options get_options "$@" # Get kernel string stuff, no need to rerun this after it's been set in options if [ -z "$INSTALL_TO_KERNEL" ];then kernel_string_info fi ### if this exits with error, no lib files will be downloaded if [ "$B_SKIP_FUNCTION" != 'true' ];then basic_startup_tests fi ### update everything, restart if not run from smxi if [ "$SKIP_RESTART" != 'true' -a "$SM_INSTALL" != 'true' -a "$B_SKIP_FUNCTION" != 'true' -a "$SKIP_WGET" != 'true' ];then check_update_script $SCRIPT_NAME "$SCRIPT_DOWNLOAD" 'default server' fi set_test_data # this will set other test data for debugging if [ "$PRINT_VER" != 'true' ];then # test for multiple video cards and select only one if [ "$CARD_COUNT" -gt 1 ];then select_card fi print_information fi ### this is separate so card can get set first for native installer set_card if [ "$NATIVE_DRIVER" != 'true' ];then detect_card_version fi ## This has to run after card version detection to log that data ## don't log the first start if restart/print output happens if [ "$PRINT_VER" != 'true' ];then create_log fi if [ "$PRINT_VER" != 'true' -a -z "$PACKAGE_MANAGER" -a "$SM_INSTALL" != 'true' -a "$AUTORUN" != 'true' ];then check_apt_aptitude fi if [ "$NATIVE_DRIVER" == 'true' ];then install_native_driver fi ### ready to set the data for version/system info if [ "$USE_DEBIAN_DRIVER" != 'true' ];then check_supported_driver # make sure user entered data is correct set_cpu_data fi # needs to be out to give print version set_version if [ "$USE_DEBIAN_DRIVER" != 'true' ];then set_download_info # also triggers the download / extract function # must be after set_version for output of data to smxi # note this must occur before binary driver install fi x_start_stop_master stop if [ "$B_SKIP_FUNCTION" != 'true' -a "$PRINT_VER" != 'true' -a "$NATIVE_DRIVER" != 'true' ];then check_install_tools fi prep_install # for testing/debugging and alt driver/card download testing, # I don't want to remove this stuff from system if [ "$B_SKIP_FUNCTION" != 'true' ];then preinstall_cleanup fi ### this is going to run either the fglrx or nvidia patch library file function ### both have same function name, so no detection is required, we did it already if [ "$USE_DEBIAN_DRIVER" != 'true' ];then run_patches if [ "$B_SKIP_FUNCTION" == 'true' ];then exit # this is just to test up to download/extract point fi run_driver_installer post_installer_steps install_fglrx_debs else update_to_nonfree_sources install_debian_drivers fi if [ "$SKIP_CONFIG" != 'true' ];then update_xorg fi final_install_steps x_start_stop_master start ###**EOF**###