Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 218 - (show annotations) (download) (as text)
Tue Mar 8 20:29:46 2005 UTC (19 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 10839 byte(s)
new

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