Annotation of /alx-src/trunk/alxconfig-ng/functions/config_x11.sh
Parent Directory | Revision Log
Revision 221 -
(hide annotations)
(download)
(as text)
Tue Mar 8 20:49:14 2005 UTC (19 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 10848 byte(s)
Tue Mar 8 20:49:14 2005 UTC (19 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 10848 byte(s)
new
1 | niro | 221 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.3 2005-03-08 20:44:32 niro Exp $ |
2 | niro | 218 | # 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 | write_x11_config() { | ||
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 | |||
98 | #xfree or xorg ? | ||
99 | xserver="$(readlink /usr/X11R6/bin/X)" | ||
100 | |||
101 | case ${xserver} in | ||
102 | Xorg) | ||
103 | xfconfig=/etc/X11/xorg.conf | ||
104 | ;; | ||
105 | XFree86) | ||
106 | xfconfig=/etc/X11/XF86Config | ||
107 | ;; | ||
108 | *) | ||
109 | echo " Unkown xserver. aborting." | ||
110 | exit 1 | ||
111 | ;; | ||
112 | esac | ||
113 | |||
114 | #got we vnc support ? | ||
115 | if [ -f /usr/X11R6/lib/modules/vnc.so ] | ||
116 | then | ||
117 | HAS_VNC="yes" | ||
118 | else | ||
119 | HAS_VNC="no" | ||
120 | fi | ||
121 | |||
122 | #show which server we use | ||
123 | echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " | ||
124 | |||
125 | #show if we have vnc | ||
126 | if [ "${HAS_VNC}" = "yes" ] | ||
127 | then | ||
128 | echo "with vnc enabled ..." | ||
129 | else | ||
130 | echo "..." | ||
131 | fi | ||
132 | |||
133 | #create a new clear xfconfig file | ||
134 | echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig} | ||
135 | echo '' >> ${xfconfig} | ||
136 | |||
137 | #write modules | ||
138 | echo '' >> ${xfconfig} | ||
139 | echo 'Section "Module"' >> ${xfconfig} | ||
140 | echo ' Load "dbe"' >> ${xfconfig} | ||
141 | echo ' SubSection "extmod"' >> ${xfconfig} | ||
142 | echo ' Option "omit xfree86-dga"' >> ${xfconfig} | ||
143 | echo ' EndSubSection' >> ${xfconfig} | ||
144 | echo ' Load "type1"' >> ${xfconfig} | ||
145 | echo ' Load "speedo"' >> ${xfconfig} | ||
146 | echo ' Load "freetype"' >> ${xfconfig} | ||
147 | echo '# Load "xtt"' >> ${xfconfig} | ||
148 | echo '# Load "glx"' >> ${xfconfig} | ||
149 | echo ' Load "dri"' >> ${xfconfig} | ||
150 | |||
151 | [ "${HAS_VNC}" = "yes" ] && echo ' Load "vnc"' >> ${xfconfig} | ||
152 | |||
153 | echo 'EndSection' >> ${xfconfig} | ||
154 | |||
155 | #fonts | ||
156 | echo '' >> ${xfconfig} | ||
157 | echo 'Section "Files"' >> ${xfconfig} | ||
158 | echo ' RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig} | ||
159 | |||
160 | case ${xserver} in | ||
161 | Xorg) | ||
162 | echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig} | ||
163 | echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig} | ||
164 | echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig} | ||
165 | echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig} | ||
166 | echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig} | ||
167 | echo ' #FontPath "/usr/share/fonts/Speedo/"' >> ${xfconfig} | ||
168 | echo ' #FontPath "/usr/share/fonts/Type1/"' >> ${xfconfig} | ||
169 | echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig} | ||
170 | echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig} | ||
171 | echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig} | ||
172 | echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig} | ||
173 | ;; | ||
174 | XFree86) | ||
175 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig} | ||
176 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig} | ||
177 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig} | ||
178 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig} | ||
179 | echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig} | ||
180 | echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"' >> ${xfconfig} | ||
181 | echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Type1/"' >> ${xfconfig} | ||
182 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig} | ||
183 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig} | ||
184 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig} | ||
185 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig} | ||
186 | ;; | ||
187 | esac | ||
188 | |||
189 | echo '# ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig} | ||
190 | echo 'EndSection' >> ${xfconfig} | ||
191 | |||
192 | #server flags | ||
193 | echo '' >> ${xfconfig} | ||
194 | echo 'Section "ServerFlags"' >> ${xfconfig} | ||
195 | echo '# Option "DontVTSwitch"' >> ${xfconfig} | ||
196 | echo '# Option "DontZap"' >> ${xfconfig} | ||
197 | echo '# Option "Dont Zoom"' >> ${xfconfig} | ||
198 | echo 'EndSection' >> ${xfconfig} | ||
199 | |||
200 | #keyboard | ||
201 | echo '' >> ${xfconfig} | ||
202 | echo 'Section "InputDevice"' >> ${xfconfig} | ||
203 | echo ' Identifier "Keyboard1"' >> ${xfconfig} | ||
204 | |||
205 | case ${xserver} in | ||
206 | Xorg) | ||
207 | echo ' Driver "kbd"' >> ${xfconfig} | ||
208 | ;; | ||
209 | XFree86) | ||
210 | echo ' Driver "Keyboard"' >> ${xfconfig} | ||
211 | ;; | ||
212 | esac | ||
213 | |||
214 | echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig} | ||
215 | echo '# Option "Xleds" "1 2 3"' >> ${xfconfig} | ||
216 | |||
217 | case ${xserver} in | ||
218 | Xorg) | ||
219 | echo ' Option "XkbRules" "xorg"' >> ${xfconfig} | ||
220 | ;; | ||
221 | XFree86) | ||
222 | echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} | ||
223 | ;; | ||
224 | esac | ||
225 | |||
226 | echo ' Option "XkbModel" "pc104"' >> ${xfconfig} | ||
227 | echo ' Option "XkbLayout" "de"' >> ${xfconfig} | ||
228 | echo 'EndSection' >> ${xfconfig} | ||
229 | |||
230 | #mouse | ||
231 | echo '' >> ${xfconfig} | ||
232 | echo 'Section "InputDevice"' >> ${xfconfig} | ||
233 | echo ' Identifier "Mouse1"' >> ${xfconfig} | ||
234 | echo ' Driver "mouse"' >> ${xfconfig} | ||
235 | echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig} | ||
236 | |||
237 | local device | ||
238 | case ${ALX_MOUSE} in | ||
239 | IMPS/2|PS/2) device=/dev/psaux;; | ||
240 | Auto) device=/dev/mouse;; | ||
241 | *) device=/dev/mouse;; | ||
242 | esac | ||
243 | |||
244 | echo ' Option "Resolution" "1200"' >> ${xfconfig} | ||
245 | |||
246 | [ "${ALX_MOUSE}" = "IMPS/2" ] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig} | ||
247 | |||
248 | echo 'EndSection' >> ${xfconfig} | ||
249 | |||
250 | #vnc keyboard && mouse | ||
251 | if [ "${HAS_VNC}" = "yes" ] | ||
252 | then | ||
253 | echo '' >> ${xfconfig} | ||
254 | echo 'Section "InputDevice"' >> ${xfconfig} | ||
255 | echo ' Identifier "vncKeyboard"' >> ${xfconfig} | ||
256 | echo ' Driver "rfbkeyb"' >> ${xfconfig} | ||
257 | echo 'EndSection' >> ${xfconfig} | ||
258 | |||
259 | echo '' >> ${xfconfig} | ||
260 | echo 'Section "InputDevice"' >> ${xfconfig} | ||
261 | echo ' Identifier "vncMouse"' >> ${xfconfig} | ||
262 | echo ' Driver "rfbmouse"' >> ${xfconfig} | ||
263 | echo 'EndSection' >> ${xfconfig} | ||
264 | fi | ||
265 | |||
266 | |||
267 | #monitor | ||
268 | if [ -x "/sbin/ddcxinfo-knoppix" ] && | ||
269 | [ "${ALX_HSYNC}" = "auto" ] || | ||
270 | [ "${ALX_VREF}" = "auto" ] | ||
271 | then | ||
272 | ddcxinfo-knoppix -monitor >> ${xfconfig} | ||
273 | else | ||
274 | echo '' >> ${xfconfig} | ||
275 | echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig} | ||
276 | echo 'Section "Monitor"' >> ${xfconfig} | ||
277 | echo ' Identifier "Monitor0"' >> ${xfconfig} | ||
278 | echo " HorizSync ${ALX_HSYNC}" >> ${xfconfig} | ||
279 | echo " VertRefresh ${ALX_VREF}" >> ${xfconfig} | ||
280 | echo ' Option "DPMS"' >> ${xfconfig} | ||
281 | echo 'EndSection' >> ${xfconfig} | ||
282 | fi | ||
283 | |||
284 | #vga | ||
285 | echo '' >> ${xfconfig} | ||
286 | echo 'Section "Device"' >> ${xfconfig} | ||
287 | echo ' Identifier "vga0"' >> ${xfconfig} | ||
288 | echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig} | ||
289 | |||
290 | #vnc server options | ||
291 | if [ "${HAS_VNC}" = "yes" ] | ||
292 | then | ||
293 | echo '' >> ${xfconfig} | ||
294 | echo ' # rfb options' >> ${xfconfig} | ||
295 | echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig} | ||
296 | echo ' Option "rfbport" "5900"' >> ${xfconfig} | ||
297 | echo ' #Option "nevershared"' >> ${xfconfig} | ||
298 | echo ' Option "alwaysshared"' >> ${xfconfig} | ||
299 | echo ' Option "dontdisconnect"' >> ${xfconfig} | ||
300 | echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig} | ||
301 | echo ' Option "httpport" "5800"' >> ${xfconfig} | ||
302 | echo ' # Option "useraccept"' >> ${xfconfig} | ||
303 | echo ' Option "usevnc"' >> ${xfconfig} | ||
304 | echo ' # Option "localhost"' >> ${xfconfig} | ||
305 | echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig} | ||
306 | echo ' # Option "viewonly"' >> ${xfconfig} | ||
307 | echo ' # Option "loginauth"' >> ${xfconfig} | ||
308 | echo '' >> ${xfconfig} | ||
309 | fi | ||
310 | |||
311 | echo 'EndSection' >> ${xfconfig} | ||
312 | |||
313 | #screens | ||
314 | echo '' >> ${xfconfig} | ||
315 | echo 'Section "Screen"' >> ${xfconfig} | ||
316 | echo ' Identifier "Screen 1"' >> ${xfconfig} | ||
317 | echo ' Device "vga0"' >> ${xfconfig} | ||
318 | echo ' Monitor "Monitor0"' >> ${xfconfig} | ||
319 | echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig} | ||
320 | echo ' Subsection "Display"' >> ${xfconfig} | ||
321 | echo " Depth ${ALX_DEPTH}" >> ${xfconfig} | ||
322 | echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig} | ||
323 | echo ' ViewPort 0 0' >> ${xfconfig} | ||
324 | echo ' EndSubsection' >> ${xfconfig} | ||
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 |