source: src-qt4/pc-xgui/resources/bin/rundetect.sh @ 1620346

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 16 months ago

Initial import of PC-BSD /current/ SVN repo

  • Property mode set to 100755
File size: 6.3 KB
Line 
1#!/bin/sh
2# xorg-gui startup script
3# Copyright 2009 PC-BSD Software
4# Descr: This script is called by /usr/local/etc/rc.d/gdm to run the time X setup
5#        wizard. It allows the user to select a resolution / refresh rate and
6#        test it before continuing into the normal KDE GUI.
7###############################################################################
8# Configuration Settings
9
10# Set all our path variables
11PATH="/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin:/usr/local/sbin"
12export PATH
13
14# Set the home directory for startx to run properly
15HOME="/root" ; export HOME
16
17# Set the log file location
18XLOG="/tmp/xsetup.log" ; export XLOG
19
20# Program Directory
21PROGDIR="/usr/local/share/pcbsd/xorg-gui" ; export PROGDIR
22
23XGUITMP="/tmp/.xgui" ; export XGUITMP
24
25TERM="cons25" ; export TERM
26clear
27
28###############################################################################
29# Start the script now
30
31# Init our tmpdir
32if [ ! -d "${XGUITMP}" ] ; then
33        mkdir -p ${XGUITMP}
34fi
35
36echo "`clear`" >/dev/console
37
38# Move any existing xorg.conf file
39if [ -e "/etc/X11/xorg.conf" ] ; then
40   mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
41fi
42
43echo "`clear`" >/dev/console
44echo "Detecting video card and monitor capabilities..." >/dev/console
45
46X -configure 2>/dev/null
47
48# Check if we have an unprobed / unknown monitor
49${PROGDIR}/scripts/checkunprobed.sh
50
51echo "`clear`" >/dev/console
52echo "Please wait... Start X-Configuration Utility" >/dev/console
53
54# Check if we need to save an existing .xinitrc file
55if [ -e "/root/.xinitrc" ] ; then
56 mv /root/.xinitrc /root/.xinitrc.xbak
57fi
58
59# Check if we need to move the .fluxbox profile
60if [ -e "/root/.fluxbox" ] ; then
61  rm -rf /root/.fluxbox.xbak 2>/dev/null
62  mv /root/.fluxbox /root/.fluxbox.xbak 2>/dev/null
63fi
64
65rm -rf /root/.fluxbox
66cp -R ${PROGDIR}/conf/.fluxbox /root/.fluxbox
67
68cd /root/
69
70
71# Recreate our log file
72if [ -e "${XLOG}" ] ; then
73  mv ${XLOG} ${XLOG}.old
74fi
75
76# Create an empty log file for appending
77echo "" > ${XLOG}
78
79
80# Remove any files from a previous attempt
81rm ${XGUITMP}/.canceled >/dev/null 2>/dev/null
82rm ${XGUITMP}/.selected >/dev/null 2>/dev/null
83rm ${XGUITMP}/.rerunxsetup >/dev/null 2>/dev/null
84rm ${XGUITMP}/.done >/dev/null 2>/dev/null
85rm ${XGUITMP}/.failed >/dev/null 2>/dev/null
86
87
88# Set the attempt number to 0
89ATTEMPT="0"
90
91###############################################################################
92# Start the detection loop
93
94while
95i=1
96do
97
98  # Save the previous xorg.conf file for troubleshooting
99  if [ -e "/etc/X11/xorg.conf" ] ; then mv /etc/X11/xorg.conf /etc/X11/xorg.conf.previous ; fi
100
101  #  Don't keep displaying the autores question
102  AUTORES="NO"
103
104  if [ "${ATTEMPT}" = "0" ] ; then
105    # Check if we are supposed to run in vesa mode
106    xvesa="NO"
107    v=`kenv xvesa`
108    if [ $? -eq 0 ]; then xvesa=$v ; fi
109
110    # Check if user requested to run in vesa mode specifically and do it
111    if [ "$xvesa" = "YES" ] ; then
112      echo "`clear`" >/dev/console
113      echo "Using failsafe VESA 1024x768 mode..." >/dev/console
114      cp ${PROGDIR}/cardDetect/XF86Config.compat /etc/X11/xorg.conf
115    else
116      # Now run the X auto-detection
117      echo "Detecting X Setup..."
118      sleep 1
119      HOME="/root" ; export HOME
120      X -configure >/dev/null 2>&1
121      cp /root/xorg.conf.new /etc/X11/xorg.conf
122
123      AUTORES="YES"
124      # Use nvidia driver
125      sed -i '' 's|"nv"|"nvidia"|g' /etc/X11/xorg.conf
126    fi
127  elif [ "${ATTEMPT}" = "1" ] ; then
128    # Try running the driver detection again
129    rm /etc/X11/xorg.conf
130    echo "`clear`" >/dev/console
131    echo "Saved configuration failed... Running failsafe-detect..." >/dev/console
132    X -configure >/dev/null 2>&1
133    # Copy over the new xorg.conf
134    cp /root/xorg.conf.new /etc/X11/xorg.conf
135
136  else
137    # Still failed, drop to VESA failsafe
138    echo "`clear`" >/dev/console
139    echo "Detected settings failed... Using failsafe VESA 1024x768 mode..." >/dev/console
140    rm /etc/X11/xorg.conf
141    cp ${PROGDIR}/cardDetect/XF86Config.compat /etc/X11/xorg.conf
142  fi
143
144  # Check if the previous attempt failed
145  if [ -e "${XGUITMP}/.failed" ]
146  then
147  # Failed display, show the failed screen
148    rm ${XGUITMP}/.failed
149    cp ${PROGDIR}/scripts/xinit-failed /root/.xinitrc
150    chmod 755 /root/.xinitrc
151  elif [ "$AUTORES" = "YES" ] ; then
152  # First time running, ask user if they want to use auto-detected resolution
153    cp ${PROGDIR}/scripts/xinit-autodetect /root/.xinitrc
154    chmod 755 /root/.xinitrc
155  else
156  # Did not fail, create normal config
157    cp ${PROGDIR}/scripts/xinit-displaywiz /root/.xinitrc
158    chmod 755 /root/.xinitrc
159  fi
160
161  echo "`clear`" >/dev/console
162  echo "Please wait... Starting X..." >/dev/console
163  sleep 1
164  # Start the X gui
165  /usr/local/bin/startx 2>>${XLOG}
166
167  # The user canceled the dialog, and chose to use the default
168  if [ -e "${XGUITMP}/.canceled" ] ; then break ; fi
169
170  # Check if a new version of xorg.conf is ready to be tested
171  if [ -e "${XGUITMP}/.xsettings.sh" ]
172  then
173    rm ${XGUITMP}/.selected >/dev/null 2>/dev/null
174
175    #### Create the new XF86Config file with the user settings
176    echo "`clear`" >/dev/console
177    echo "Generating new Xorg configuration file..." >/dev/console
178    ${PROGDIR}/bin/setupconf.sh >>${XLOG} 2>>${XLOG}
179
180    ##### Copy the xinitrc file
181    cp ${PROGDIR}/scripts/xinit-check /root/.xinitrc
182    chmod 755 /root/.xinitrc
183
184    echo "`clear`" >/dev/console
185    echo "Please wait... Starting X..." >/dev/console
186    sleep 1
187    /usr/local/bin/startx 2>>${XLOG}
188  fi
189
190  if [ -e "${XGUITMP}/.selected" ] ; then
191    break
192  else
193    echo "failed" > ${XGUITMP}/.failed
194  fi
195
196  # Check if the X startup was a success
197  if [ ! -e "${XGUITMP}/.xstartupsuccess" ] ; then
198    ATTEMPT="`expr $ATTEMPT + 1`"
199    rm ${XGUITMP}/.failed
200  else
201    rm ${XGUITMP}/.xstartupsuccess
202  fi
203
204  # Removed any saved settings file
205  rm ${XGUITMP}/.xsettings.sh
206
207done
208
209
210rm /root/.xinitrc >/dev/null 2>/dev/null
211# Check if we need to save an existing .xinitrc file
212if [ -e "/root/.xinitrc.xbak" ] ; then
213   mv /root/.xinitrc.xbak /etc/.xinitrc
214fi
215
216# Check if we need to move the .fluxbox profile
217if [ -e "/root/.fluxbox.xbak" ] ; then
218  rm -rf /root/.fluxbox >/dev/null 2>/dev/null
219  mv /root/.fluxbox.xbak /root/.fluxbox
220fi
221
222rm ${XGUITMP}/.rerunxsetup >/dev/null 2>/dev/null
223rm ${XGUITMP}/.skipauto >/dev/null 2>/dev/null
224echo "`clear`" >/dev/console
225echo "Preparing to start the desktop..." >/dev/console
226sleep 1
227exit 0
Note: See TracBrowser for help on using the repository browser.