All pastes #416788 Raw Edit

Someone

public text v1 · immutable
#416788 ·published 2007-03-30 13:44 UTC
rendered paste body
#!/bin/sh
# Copyright 2001 BSDi, Inc, Concord, CA.  Written by volkerdi@slackware.com.
# Copyright 2004 Slackware Linux, Inc., Concord, CA.
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Modified by rs Lange of Vector Linux. Formally called xorgsetup
vdir=`dirname $0`
. $vdir/vasm-functions
check_root

if [ $DISPLAY ]; then
  DIALOG=Xdialog
else
  DIALOG=dialog
fi

# If we aren't root, bail:
if [ "$UID" = "0" ]; then
  TMP=/var/log/setup/tmp
else
  clear
  echo "Only root can configure X......bailing"
  sleep 8
  exit
fi

# Now, this wouldn't make much sense either:
if [ ! -x /usr/X11R6/bin/Xorg ]; then
  echo "No X found so bailing............"
  sleep 8
  exit
fi

##############################################################
##now lets get a default screen resolution
clear
$DIALOG --title "SELECT DEFAULT MONITOR RESOLUTION" \
 --menu "Please select your default screen resolution from the menu below. \n
The resolution selected should be the best your monitor will handle. \n
For most modern monitors a selection of 1024X768 is a good choice, older monitors \n
may only be able to do 800X600. Please select a resolution now." 16 70 6 \
"640x480" "The most basic vga monitor" \
"800x600" "Any SVGA monitor should be able to do this"  \
"1024x768" "If you have a recent 15 or 17 inch monitor OK" \
"1280x1024" "Very new monitors or lcd screens" \
"1600x1200" "You know if you have this one...wow!" \
"none" "Choose this if you have no idea X will try to figure it out" 2> $TMP/resolution
if [ ! $? = 0 ]; then
rm -f $TMP/resolution
exit 1
fi
res=`cat $TMP/resolution`

##set resolution modes
if [ "$res" = "640x480" ]; then
  finalres="Modes \"640x480\" \"800x600\""
fi
if [ "$res" = "800x600" ]; then
  finalres="Modes \"800x600\" \"640x480\""
fi
if [ "$res" = "1024x768" ]; then
  finalres="Modes \"1024x768\" \"800x600\" \"640x480\""
fi
if [ "$res" = "1280x1024" ]; then
  finalres="Modes \"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""
fi
if [ "$res" = "1600x1200" ]; then
  finalres="Modes \"1600x1200\" \"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""
fi


#check the keyboard
$DIALOG --title "KEEP DEFAULT KEYBOARD MAP AND LAYOUT" \
--yesno "Would you like to KEEP the default (US) keyboard setup? \n
 if you choose NO you can change both the keymap and keyboard type\n
 from the default Setting \
US and pc102" 8 70 2> /dev/null
if [ ! $? = 0 ]; then
  vxkbset
fi

 
 ##now keyboard setting if none us
 if [ ! $XKBMAP ]; then
   XKBMAP=us
 fi
 if [ $XKBMAP ]; then
  if echo $LINE | grep Driver | grep kbd 1> /dev/null ; then
    echo "Option  \"XkbLayout\"  \"$XKBMAP\"   ## KEYBOARD_MAP!" >> /etc/X11/xorg.conf
  fi
 fi
 if [ $XKBMODEL ]; then
  if echo $LINE | grep Driver | grep kbd 1> /dev/null ; then
    echo "Option  \"XkbModel\"  \"$XKBMODEL\"" >> /etc/X11/xorg.conf
  fi
 fi
 if [ $XKBVAR ]; then
  if echo $LINE | grep Driver | grep kbd 1> /dev/null ; then
    echo "Option  \"Xkbvariant\"  \"$XKBVAR\"" >> /etc/X11/xorg.conf
  fi
 fi
 ##last monitor refresh if not auto detected
 if [ "$fixsync" = "yes" ]; then
  if echo $LINE | grep ModelName 1> /dev/null ; then
    echo "HorizSync $horiz" >> /etc/X11/xorg.conf
  fi
 fi
 if [ "$fixsync" = "yes" ]; then
  if echo $LINE | grep ModelName 1> /dev/null ; then
    echo "VertRefresh $vert" >> /etc/X11/xorg.conf
  fi
 fi				
done

echo Section \"DRI\" >> /etc/X11/xorg.conf
echo 	Mode         0666 >> /etc/X11/xorg.conf
echo EndSection >> /etc/X11/xorg.conf

rm -f $TMP/colordepth
rm -f $TMP/resolution
clear

##  Test for 2 video cards
if [ `grep "^Driver" /etc/X11/xorg.conf | grep -v kbd | grep -v mouse | wc | cut -d " " -f7` -gt 1 ]; then
     cards=`grep "^Vendor" /etc/X11/xorg.conf | grep -v Mon | cut -d " " -f3 | cut -c 2-`
     for i in $cards; do
       echo $i >>/tmp/cards
       card[$j]="$i"
       j=`expr $j + 1`
     done
     $DCMD --backtitle "$BACKTITLE" --title "Choose Video Card" --menu "\n
     We have found more than 1 video card, and for X to work \n
     we need to know which card your monitor is connected to.\n
     Choose which video card you would like to use" \
     20 74 8 \
     ${card[0]} ${card[0]} \
     ${card[1]} ${card[1]} \
     ${card[2]} ${card[2]} \
     2> $freply

     cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

     card1=`cat $freply`
     card2=`cat /tmp/cards | grep -v $card1`
     sed '/Card[0-2]/ d' /etc/X11/xorg.conf > /etc/X11/xorg.conf.1
     rm /etc/X11/xorg.conf
     cat /etc/X11/xorg.conf.1 | while read LINE ; do
       echo "$LINE" >> /etc/X11/xorg.conf.2
       if echo $LINE | grep $card1 1> /dev/null ; then
         echo Identifier  \"Card0\" >> /etc/X11/xorg.conf.2
       fi
       if echo $LINE | grep Section | grep Screen 1> /dev/null ; then
         echo Device     \"Card0\" >> /etc/X11/xorg.conf.2
       fi
     done
     cat /etc/X11/xorg.conf.2 | while read LINE ; do
       echo "$LINE" >> /etc/X11/xorg.conf
       if echo $LINE | grep $card2 1> /dev/null ; then
         echo Identifier  \"Card1\" >> /etc/X11/xorg.conf
       fi
     done
       rm /tmp/cards
       rm /etc/X11/xorg.conf.1
       rm /etc/X11/xorg.conf.2
fi

### intel i810 video has a problem without this hack
cat /etc/X11/xorg.conf | grep Driver | grep i810 1> /dev/null

if [ $? = 0 ]; then
uname -r | cut -f 1,2 -d '.' > $TMP/kernel
kernel=`cat $TMP/kernel`
rm -f $TMP/kernel
if [ $kernel = "2.6" ]; then
/sbin/modprobe intel-agp && echo "/sbin/modprobe intel-agp" >> /etc/rc.d/rc.modules
fi
fi
echo "Testing configuration...........hold tight!!!!"
sleep 2
Xorg -probeonly :2 2> /dev/null
if [ $? = 0 ]; then



$DIALOG --title "X WAS CONFIGURED SUCCESSFULLY" \
  --msgbox "Your new X configuration file has been saved to /etc/X11/xorg.conf.
You may still need to add or adjust some values in the file to achieve the desired
screen resolution.  For example, some monitors would require \"HorizSync 30-55\" in
the \"Monitor\" section of the configuration file.  For complete information about 
making these adjustments, please refer to \"man xorg.conf\"." \
  11 76

else
$DIALOG --title "ERROR ERROR" \
 --yesno "There was an error in your X configuration. Would you like to edit the \n
 /etc/X11/xorg.conf file as autoconfig must have stumbled somewhere? \n
 Choosing yes here will start a text mode configuration utility. \n
 Choose no if you wish to edit later from the installation." \
 11 66 2> /dev/null
 if [ $? = 0 ]; then
 /usr/X11R6/bin/xorgcfg -textmode
 fi

 exit 1
 fi