Magellan Linux

Contents of /alx-src/trunk/alxconfig-ng/functions/config_x11.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 343 - (show annotations) (download) (as text)
Sun Oct 9 21:31:54 2005 UTC (18 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 10847 byte(s)
- fixed whitespaces
- using now mysqldo from mysqlfunctions
- using better literal tests ( [[ xx ]] construct )

1 # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.9 2005-10-09 21:31:54 niro Exp $
2 # configures the x11 server on the host via mysql db settings
3
4 get_x11_settings()
5 {
6 local x i all DB_X11SETTINGS
7
8 # autodetect or not ?
9 if [ $(mysqldo "select monitorid from cfg_graphic where serial='${ALX_SERIAL}'") -gt 0 ]
10 then
11 # settings from db
12
13 all=$(mysqldo "select cfg_graphic.module,
14 cfg_graphic.resolution,
15 cfg_graphic.depth,
16 list_monitors.vendor,
17 list_monitors.model,
18 list_monitors.hsync,
19 list_monitors.vrefresh
20 from list_monitors
21 inner join cfg_graphic
22 on cfg_graphic.monitorid=list_monitors.id
23 and cfg_graphic.serial='${ALX_SERIAL}';")
24
25 # split'em up and put 'em in an array
26 declare -i i=0
27 for x in ${all}
28 do
29 DB_X11SETTINGS[${i}]="${x}"
30 ((i++))
31 done
32
33 # and now put them in usable var names and export them systemwide
34 export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"
35 export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"
36 export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"
37 export ALX_VENDOR="${DB_X11SETTINGS[3]:=NULL}"
38 export ALX_MODEL="${DB_X11SETTINGS[4]:=NULL}"
39 export ALX_HSYNC="${DB_X11SETTINGS[5]:=NULL}"
40 export ALX_VREF="${DB_X11SETTINGS[6]:=NULL}"
41 else
42 # autodetect
43 all=$(mysqldo "select module,
44 resolution,
45 depth
46 from cfg_graphic where serial='${ALX_SERIAL}'")
47
48 # split'em up and put 'em in an array
49 declare -i i=0
50 for x in ${all}
51 do
52 DB_X11SETTINGS[${i}]="${x}"
53 ((i++))
54 done
55
56 # and now put them in usable var names and export them systemwide
57 export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"
58 export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"
59 export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"
60 export ALX_VENDOR="Autodetected"
61 export ALX_MODEL="Monitor"
62 export ALX_HSYNC="auto"
63 export ALX_VREF="auto"
64 fi
65
66 # which input devices are we using ?
67 ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")
68 export ALX_MOUSE
69 }
70
71 config_x11()
72 {
73 # get our settings from the db
74 get_x11_settings
75
76 local xserver
77 local xfconfig
78 local HAS_VNC
79 local HAS_REALVNC
80
81 # xfree or xorg ?
82 xserver="$(readlink /usr/X11R6/bin/X)"
83
84 case ${xserver} in
85 Xorg)
86 xfconfig=/etc/X11/xorg.conf
87 ;;
88 XFree86)
89 xfconfig=/etc/X11/XF86Config
90 ;;
91 *)
92 echo " Unkown xserver. aborting."
93 exit 1
94 ;;
95 esac
96
97 # got we vnc support ?
98 if [ -f /usr/X11R6/lib/modules/vnc.so ]
99 then
100 HAS_VNC="yes"
101 else
102 HAS_VNC="no"
103 fi
104
105 if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]
106 then
107 HAS_REALVNC="yes"
108 else
109 HAS_REALVNC="no"
110 fi
111
112 # show which server we use
113 echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
114
115 # show if we have vnc
116 if [[ ${HAS_VNC} = yes ]]
117 then
118 echo "with vnc enabled ..."
119 elif [[ ${HAS_REALVNC} = yes ]]
120 then
121 echo "with realvnc enabled ..."
122 else
123 echo "..."
124 fi
125
126 # create a new clear xfconfig file
127 echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}
128 echo '' >> ${xfconfig}
129
130 # write modules
131 echo '' >> ${xfconfig}
132 echo 'Section "Module"' >> ${xfconfig}
133 echo ' Load "dbe"' >> ${xfconfig}
134 echo ' SubSection "extmod"' >> ${xfconfig}
135 echo ' Option "omit xfree86-dga"' >> ${xfconfig}
136 echo ' EndSubSection' >> ${xfconfig}
137 echo ' Load "type1"' >> ${xfconfig}
138 echo ' Load "speedo"' >> ${xfconfig}
139 echo ' Load "freetype"' >> ${xfconfig}
140 echo '# Load "xtt"' >> ${xfconfig}
141 echo '# Load "glx"' >> ${xfconfig}
142 echo ' Load "dri"' >> ${xfconfig}
143
144 [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
145 [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
146
147 echo 'EndSection' >> ${xfconfig}
148
149 # fonts
150 echo '' >> ${xfconfig}
151 echo 'Section "Files"' >> ${xfconfig}
152 echo ' RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig}
153
154 case ${xserver} in
155 Xorg)
156 echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig}
157 echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig}
158 echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
159 echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
160 echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}
161 echo ' #FontPath "/usr/share/fonts/Speedo/"' >> ${xfconfig}
162 echo ' #FontPath "/usr/share/fonts/Type1/"' >> ${xfconfig}
163 echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig}
164 echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig}
165 echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig}
166 echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig}
167 ;;
168 XFree86)
169 echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig}
170 echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}
171 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}
172 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}
173 echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}
174 echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"' >> ${xfconfig}
175 echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Type1/"' >> ${xfconfig}
176 echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}
177 echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}
178 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}
179 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig}
180 ;;
181 esac
182
183 echo '# ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig}
184 echo 'EndSection' >> ${xfconfig}
185
186 # server flags
187 echo '' >> ${xfconfig}
188 echo 'Section "ServerFlags"' >> ${xfconfig}
189 echo '# Option "DontVTSwitch"' >> ${xfconfig}
190 echo '# Option "DontZap"' >> ${xfconfig}
191 echo '# Option "Dont Zoom"' >> ${xfconfig}
192 echo 'EndSection' >> ${xfconfig}
193
194 # keyboard
195 echo '' >> ${xfconfig}
196 echo 'Section "InputDevice"' >> ${xfconfig}
197 echo ' Identifier "Keyboard1"' >> ${xfconfig}
198
199 case ${xserver} in
200 Xorg)
201 echo ' Driver "kbd"' >> ${xfconfig}
202 ;;
203 XFree86)
204 echo ' Driver "Keyboard"' >> ${xfconfig}
205 ;;
206 esac
207
208 echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig}
209 echo '# Option "Xleds" "1 2 3"' >> ${xfconfig}
210
211 case ${xserver} in
212 Xorg)
213 echo ' Option "XkbRules" "xorg"' >> ${xfconfig}
214 ;;
215 XFree86)
216 echo ' Option "XkbRules" "xfree86"' >> ${xfconfig}
217 ;;
218 esac
219
220 echo ' Option "XkbModel" "pc105"' >> ${xfconfig}
221 echo ' Option "XkbLayout" "de"' >> ${xfconfig}
222 echo 'EndSection' >> ${xfconfig}
223
224 # mouse
225 echo '' >> ${xfconfig}
226 echo 'Section "InputDevice"' >> ${xfconfig}
227 echo ' Identifier "Mouse1"' >> ${xfconfig}
228 echo ' Driver "mouse"' >> ${xfconfig}
229 echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig}
230
231 local device
232 case ${ALX_MOUSE} in
233 IMPS/2|PS/2) device=/dev/psaux;;
234 Auto) device=/dev/mouse;;
235 *) device=/dev/mouse;;
236 esac
237 echo " Option \"Device\" \"${device}\"" >> ${xfconfig}
238 echo ' Option "Resolution" "1200"' >> ${xfconfig}
239
240 [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig}
241
242 echo 'EndSection' >> ${xfconfig}
243
244 # vnc keyboard && mouse
245 if [[ ${HAS_VNC} = yes ]]
246 then
247 echo '' >> ${xfconfig}
248 echo 'Section "InputDevice"' >> ${xfconfig}
249 echo ' Identifier "vncKeyboard"' >> ${xfconfig}
250 echo ' Driver "rfbkeyb"' >> ${xfconfig}
251 echo 'EndSection' >> ${xfconfig}
252
253 echo '' >> ${xfconfig}
254 echo 'Section "InputDevice"' >> ${xfconfig}
255 echo ' Identifier "vncMouse"' >> ${xfconfig}
256 echo ' Driver "rfbmouse"' >> ${xfconfig}
257 echo 'EndSection' >> ${xfconfig}
258 fi
259
260 # monitor
261 if [ -x "/sbin/ddcxinfo-knoppix" ] &&
262 [[ ${ALX_HSYNC} = auto ]] ||
263 [[ ${ALX_VREF} = auto ]]
264 then
265 ddcxinfo-knoppix -monitor >> ${xfconfig}
266 else
267 echo '' >> ${xfconfig}
268 echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig}
269 echo 'Section "Monitor"' >> ${xfconfig}
270 echo ' Identifier "Monitor0"' >> ${xfconfig}
271 echo " HorizSync ${ALX_HSYNC}" >> ${xfconfig}
272 echo " VertRefresh ${ALX_VREF}" >> ${xfconfig}
273 echo ' Option "DPMS"' >> ${xfconfig}
274 echo 'EndSection' >> ${xfconfig}
275 fi
276
277 # vga
278 echo '' >> ${xfconfig}
279 echo 'Section "Device"' >> ${xfconfig}
280 echo ' Identifier "vga0"' >> ${xfconfig}
281 echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig}
282
283 # vnc server options
284 if [[ ${HAS_VNC} = yes ]]
285 then
286 echo '' >> ${xfconfig}
287 echo ' # rfb options' >> ${xfconfig}
288 echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig}
289 echo ' Option "rfbport" "5900"' >> ${xfconfig}
290 echo ' #Option "nevershared"' >> ${xfconfig}
291 echo ' Option "alwaysshared"' >> ${xfconfig}
292 echo ' Option "dontdisconnect"' >> ${xfconfig}
293 echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig}
294 echo ' Option "httpport" "5800"' >> ${xfconfig}
295 echo ' # Option "useraccept"' >> ${xfconfig}
296 echo ' Option "usevnc"' >> ${xfconfig}
297 echo ' # Option "localhost"' >> ${xfconfig}
298 echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig}
299 echo ' # Option "viewonly"' >> ${xfconfig}
300 echo ' # Option "loginauth"' >> ${xfconfig}
301 echo '' >> ${xfconfig}
302 fi
303
304 echo 'EndSection' >> ${xfconfig}
305
306 # screens
307 echo '' >> ${xfconfig}
308 echo 'Section "Screen"' >> ${xfconfig}
309 echo ' Identifier "Screen 1"' >> ${xfconfig}
310 echo ' Device "vga0"' >> ${xfconfig}
311 echo ' Monitor "Monitor0"' >> ${xfconfig}
312 echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}
313 echo ' Subsection "Display"' >> ${xfconfig}
314 echo " Depth ${ALX_DEPTH}" >> ${xfconfig}
315 echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig}
316 echo ' ViewPort 0 0' >> ${xfconfig}
317 echo ' EndSubsection' >> ${xfconfig}
318
319 if [[ ${HAS_REALVNC} = yes ]]
320 then
321 echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
322 echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
323 echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
324 fi
325 echo 'EndSection' >> ${xfconfig}
326
327 # server layout
328 echo '' >> ${xfconfig}
329 echo 'Section "ServerLayout"' >> ${xfconfig}
330 echo ' Identifier "Simple Layout"' >> ${xfconfig}
331 echo ' Screen "Screen 1"' >> ${xfconfig}
332 echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
333 echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
334
335 # load vnc keyboard && mouse
336 if [[ ${HAS_VNC} = yes ]]
337 then
338 echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig}
339 echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}
340 fi
341
342 echo 'EndSection' >> ${xfconfig}
343
344 # dri (here disabled, use default of xserver)
345 echo '' >> ${xfconfig}
346 echo '# Section "DRI"' >> ${xfconfig}
347 echo '# Mode 0666' >> ${xfconfig}
348 echo '# EndSection' >> ${xfconfig}
349 }
350