Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 325 - (show annotations) (download) (as text)
Tue Sep 6 07:45:00 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 11445 byte(s)
added support for realvnc

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