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

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 2513d5a was 2513d5a, checked in by Kris Moore <kris@…>, 12 months ago

Don't need to do the X -configure stuff for the display wizard either,
causes problems with some Intel chipsets

  • Property mode set to 100755
File size: 5.8 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 "Please wait... Start X-Configuration Utility" >/dev/console
45
46# Check if we need to save an existing .xinitrc file
47if [ -e "/root/.xinitrc" ] ; then
48 mv /root/.xinitrc /root/.xinitrc.xbak
49fi
50
51# Check if we need to move the .fluxbox profile
52if [ -e "/root/.fluxbox" ] ; then
53  rm -rf /root/.fluxbox.xbak 2>/dev/null
54  mv /root/.fluxbox /root/.fluxbox.xbak 2>/dev/null
55fi
56
57rm -rf /root/.fluxbox
58cp -R ${PROGDIR}/conf/.fluxbox /root/.fluxbox
59
60cd /root/
61
62
63# Recreate our log file
64if [ -e "${XLOG}" ] ; then
65  mv ${XLOG} ${XLOG}.old
66fi
67
68# Create an empty log file for appending
69echo "" > ${XLOG}
70
71
72# Remove any files from a previous attempt
73rm ${XGUITMP}/.canceled >/dev/null 2>/dev/null
74rm ${XGUITMP}/.selected >/dev/null 2>/dev/null
75rm ${XGUITMP}/.rerunxsetup >/dev/null 2>/dev/null
76rm ${XGUITMP}/.done >/dev/null 2>/dev/null
77rm ${XGUITMP}/.failed >/dev/null 2>/dev/null
78
79
80# Set the attempt number to 0
81ATTEMPT="0"
82
83###############################################################################
84# Start the detection loop
85
86while
87i=1
88do
89
90  # Save the previous xorg.conf file for troubleshooting
91  if [ -e "/etc/X11/xorg.conf" ] ; then mv /etc/X11/xorg.conf /etc/X11/xorg.conf.previous ; fi
92
93  #  Don't keep displaying the autores question
94  AUTORES="NO"
95
96  if [ "${ATTEMPT}" = "0" ] ; then
97    # Check if we are supposed to run in vesa mode
98    xvesa="NO"
99    v=`kenv xvesa`
100    if [ $? -eq 0 ]; then xvesa=$v ; fi
101
102    # Check if user requested to run in vesa mode specifically and do it
103    if [ "$xvesa" = "YES" ] ; then
104      echo "`clear`" >/dev/console
105      echo "Using failsafe VESA 1024x768 mode..." >/dev/console
106      cp ${PROGDIR}/cardDetect/XF86Config.compat /etc/X11/xorg.conf
107    else
108      AUTORES="YES"
109    fi
110  elif [ "${ATTEMPT}" = "1" ] ; then
111    # Try running the driver detection again
112    rm /etc/X11/xorg.conf
113    echo "`clear`" >/dev/console
114    echo "Saved configuration failed... Running failsafe-detect..." >/dev/console
115    X -configure >/dev/null 2>&1
116    # Copy over the new xorg.conf
117    cp /root/xorg.conf.new /etc/X11/xorg.conf
118
119  else
120    # Still failed, drop to VESA failsafe
121    echo "`clear`" >/dev/console
122    echo "Detected settings failed... Using failsafe VESA 1024x768 mode..." >/dev/console
123    rm /etc/X11/xorg.conf
124    cp ${PROGDIR}/cardDetect/XF86Config.compat /etc/X11/xorg.conf
125  fi
126
127  # Check if the previous attempt failed
128  if [ -e "${XGUITMP}/.failed" ]
129  then
130  # Failed display, show the failed screen
131    rm ${XGUITMP}/.failed
132    cp ${PROGDIR}/scripts/xinit-failed /root/.xinitrc
133    chmod 755 /root/.xinitrc
134  elif [ "$AUTORES" = "YES" ] ; then
135  # First time running, ask user if they want to use auto-detected resolution
136    cp ${PROGDIR}/scripts/xinit-autodetect /root/.xinitrc
137    chmod 755 /root/.xinitrc
138  else
139  # Did not fail, create normal config
140    cp ${PROGDIR}/scripts/xinit-displaywiz /root/.xinitrc
141    chmod 755 /root/.xinitrc
142  fi
143
144  echo "`clear`" >/dev/console
145  echo "Please wait... Starting X..." >/dev/console
146  sleep 1
147  # Start the X gui
148  /usr/local/bin/startx 2>>${XLOG}
149
150  # The user canceled the dialog, and chose to use the default
151  if [ -e "${XGUITMP}/.canceled" ] ; then break ; fi
152
153  # Check if a new version of xorg.conf is ready to be tested
154  if [ -e "${XGUITMP}/.xsettings.sh" ]
155  then
156    rm ${XGUITMP}/.selected >/dev/null 2>/dev/null
157
158    #### Create the new XF86Config file with the user settings
159    echo "`clear`" >/dev/console
160    echo "Generating new Xorg configuration file..." >/dev/console
161    ${PROGDIR}/bin/setupconf.sh >>${XLOG} 2>>${XLOG}
162
163    ##### Copy the xinitrc file
164    cp ${PROGDIR}/scripts/xinit-check /root/.xinitrc
165    chmod 755 /root/.xinitrc
166
167    echo "`clear`" >/dev/console
168    echo "Please wait... Starting X..." >/dev/console
169    sleep 1
170    /usr/local/bin/startx 2>>${XLOG}
171  fi
172
173  if [ -e "${XGUITMP}/.selected" ] ; then
174    break
175  else
176    echo "failed" > ${XGUITMP}/.failed
177  fi
178
179  # Check if the X startup was a success
180  if [ ! -e "${XGUITMP}/.xstartupsuccess" ] ; then
181    ATTEMPT="`expr $ATTEMPT + 1`"
182    rm ${XGUITMP}/.failed
183  else
184    rm ${XGUITMP}/.xstartupsuccess
185  fi
186
187  # Removed any saved settings file
188  rm ${XGUITMP}/.xsettings.sh
189
190done
191
192
193rm /root/.xinitrc >/dev/null 2>/dev/null
194# Check if we need to save an existing .xinitrc file
195if [ -e "/root/.xinitrc.xbak" ] ; then
196   mv /root/.xinitrc.xbak /etc/.xinitrc
197fi
198
199# Check if we need to move the .fluxbox profile
200if [ -e "/root/.fluxbox.xbak" ] ; then
201  rm -rf /root/.fluxbox >/dev/null 2>/dev/null
202  mv /root/.fluxbox.xbak /root/.fluxbox
203fi
204
205rm ${XGUITMP}/.rerunxsetup >/dev/null 2>/dev/null
206rm ${XGUITMP}/.skipauto >/dev/null 2>/dev/null
207echo "`clear`" >/dev/console
208echo "Preparing to start the desktop..." >/dev/console
209sleep 1
210exit 0
Note: See TracBrowser for help on using the repository browser.