Magellan Linux

Contents of /alx-src/branches/alxconf_20060908/functions/config_x11.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1586 - (show annotations) (download) (as text)
Fri Nov 26 09:32:30 2010 UTC (13 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 9132 byte(s)
-support tigervnc
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 # autodetect
8 all=$(mysqldo "select module,
9 resolution,
10 depth,
11 refresh_rate
12 from cfg_graphic where serial='${ALX_SERIAL}'")
13
14 # split'em up and put 'em in an array
15 declare -i i=0
16 for x in ${all}
17 do
18 DB_X11SETTINGS[${i}]="${x}"
19 ((i++))
20 done
21
22 # and now put them in usable var names and export them systemwide
23 export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"
24 export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"
25 export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"
26 export ALX_REFRESH_RATE="${DB_X11SETTINGS[3]:=NULL}"
27
28 # which input devices are we using ?
29 ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")
30 export ALX_MOUSE
31 }
32
33 config_x11()
34 {
35 # get our settings from the db
36 get_x11_settings
37
38 local xserver
39 local xfconfig
40 local HAS_VNC
41 local HAS_REALVNC
42 local HAS_TIGERVNC
43
44 # xfree or xorg ?
45 xserver="$(readlink /usr/X11R6/bin/X)"
46
47 case ${xserver} in
48 Xorg) xfconfig=/etc/X11/xorg.conf ;;
49 XFree86) xfconfig=/etc/X11/XF86Config ;;
50 *) echo " Unkown xserver. aborting."; exit 1 ;;
51 esac
52
53 # got we vnc support ?
54 if [ -f /usr/X11R6/lib/modules/vnc.so ]
55 then
56 HAS_VNC="yes"
57 else
58 HAS_VNC="no"
59 fi
60
61 if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]
62 then
63 HAS_REALVNC="yes"
64 else
65 HAS_REALVNC="no"
66 fi
67
68 if [ -f /usr/X11R6/lib/modules/extensions/libvnc.so ]
69 then
70 HAS_TIGERVNC="yes"
71 else
72 HAS_TIGERVNC="no"
73 fi
74
75 # show which server we use
76 echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
77
78 # show if we have vnc
79 if [[ ${HAS_VNC} = yes ]]
80 then
81 echo "with vnc enabled ..."
82 elif [[ ${HAS_REALVNC} = yes ]]
83 then
84 echo "with realvnc enabled ..."
85 elif [[ ${HAS_TIGERVNC} = yes ]]
86 then
87 echo "with tigervnc enabled ..."
88 else
89 echo "..."
90 fi
91
92 # create a new clear xfconfig file
93 echo '# Generated with alxconfig-ng.' > ${xfconfig}
94 echo '' >> ${xfconfig}
95
96 # write modules
97 echo '' >> ${xfconfig}
98 echo 'Section "Module"' >> ${xfconfig}
99 echo ' Load "dbe"' >> ${xfconfig}
100 echo ' SubSection "extmod"' >> ${xfconfig}
101 echo ' Option "omit xfree86-dga"' >> ${xfconfig}
102 echo ' EndSubSection' >> ${xfconfig}
103 echo ' Load "freetype"' >> ${xfconfig}
104 echo '# Load "glx"' >> ${xfconfig}
105 echo ' Load "dri"' >> ${xfconfig}
106
107 [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
108 [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
109 [[ ${HAS_TIGERVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
110
111 echo 'EndSection' >> ${xfconfig}
112
113 # fonts
114 echo '' >> ${xfconfig}
115 echo 'Section "Files"' >> ${xfconfig}
116
117 case ${xserver} in
118 Xorg)
119 echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig}
120 echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig}
121 echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
122 echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
123 echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig}
124 echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig}
125 echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig}
126 echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig}
127 ;;
128 XFree86)
129 echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig}
130 echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}
131 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}
132 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}
133 echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}
134 echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}
135 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}
136 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig}
137 ;;
138 esac
139
140 echo 'EndSection' >> ${xfconfig}
141
142 # server flags
143 echo '' >> ${xfconfig}
144 echo 'Section "ServerFlags"' >> ${xfconfig}
145 echo '# Option "DontVTSwitch"' >> ${xfconfig}
146 echo '# Option "DontZap"' >> ${xfconfig}
147 echo '# Option "Dont Zoom"' >> ${xfconfig}
148 echo 'EndSection' >> ${xfconfig}
149
150 # keyboard
151 echo '' >> ${xfconfig}
152 echo 'Section "InputDevice"' >> ${xfconfig}
153 echo ' Identifier "Keyboard1"' >> ${xfconfig}
154
155 case ${xserver} in
156 Xorg) echo ' Driver "kbd"' >> ${xfconfig} ;;
157 XFree86) echo ' Driver "Keyboard"' >> ${xfconfig} ;;
158 esac
159
160 echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig}
161 echo '# Option "Xleds" "1 2 3"' >> ${xfconfig}
162
163 case ${xserver} in
164 Xorg) echo ' Option "XkbRules" "xorg"' >> ${xfconfig} ;;
165 XFree86) echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} ;;
166 esac
167
168 echo ' Option "XkbModel" "pc105"' >> ${xfconfig}
169 echo ' Option "XkbLayout" "de"' >> ${xfconfig}
170 echo 'EndSection' >> ${xfconfig}
171
172 # mouse
173 echo '' >> ${xfconfig}
174 echo 'Section "InputDevice"' >> ${xfconfig}
175 echo ' Identifier "Mouse1"' >> ${xfconfig}
176 echo ' Driver "mouse"' >> ${xfconfig}
177 echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig}
178
179 local device
180 case ${ALX_MOUSE} in
181 IMPS/2|PS/2) device=/dev/psaux;;
182 Auto) device=/dev/mouse;;
183 *) device=/dev/mouse;;
184 esac
185 echo " Option \"Device\" \"${device}\"" >> ${xfconfig}
186 echo ' Option "Resolution" "1200"' >> ${xfconfig}
187
188 [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig}
189
190 echo 'EndSection' >> ${xfconfig}
191
192 # vnc keyboard && mouse
193 if [[ ${HAS_VNC} = yes ]]
194 then
195 echo '' >> ${xfconfig}
196 echo 'Section "InputDevice"' >> ${xfconfig}
197 echo ' Identifier "vncKeyboard"' >> ${xfconfig}
198 echo ' Driver "rfbkeyb"' >> ${xfconfig}
199 echo 'EndSection' >> ${xfconfig}
200
201 echo '' >> ${xfconfig}
202 echo 'Section "InputDevice"' >> ${xfconfig}
203 echo ' Identifier "vncMouse"' >> ${xfconfig}
204 echo ' Driver "rfbmouse"' >> ${xfconfig}
205 echo 'EndSection' >> ${xfconfig}
206 fi
207
208 # monitor
209 echo 'Section "Monitor"' >> ${xfconfig}
210 echo ' Identifier "Monitor0"' >> ${xfconfig}
211 echo ' Option "DPMS"' >> ${xfconfig}
212 echo '' >> ${xfconfig}
213 # add cvt modelines
214 local cvt="/usr/X11R6/bin/cvt"
215 local modeline
216 modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
217 echo "${modeline}" >> ${xfconfig}
218 echo 'EndSection' >> ${xfconfig}
219
220 # vga
221 echo '' >> ${xfconfig}
222 echo 'Section "Device"' >> ${xfconfig}
223 echo ' Identifier "vga0"' >> ${xfconfig}
224 echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig}
225
226 # vnc server options
227 if [[ ${HAS_VNC} = yes ]]
228 then
229 echo '' >> ${xfconfig}
230 echo ' # rfb options' >> ${xfconfig}
231 echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig}
232 echo ' Option "rfbport" "5900"' >> ${xfconfig}
233 echo ' #Option "nevershared"' >> ${xfconfig}
234 echo ' Option "alwaysshared"' >> ${xfconfig}
235 echo ' Option "dontdisconnect"' >> ${xfconfig}
236 echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig}
237 echo ' Option "httpport" "5800"' >> ${xfconfig}
238 echo ' # Option "useraccept"' >> ${xfconfig}
239 echo ' Option "usevnc"' >> ${xfconfig}
240 echo ' # Option "localhost"' >> ${xfconfig}
241 echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig}
242 echo ' # Option "viewonly"' >> ${xfconfig}
243 echo ' # Option "loginauth"' >> ${xfconfig}
244 echo '' >> ${xfconfig}
245 fi
246
247 echo 'EndSection' >> ${xfconfig}
248
249 # screens
250 echo '' >> ${xfconfig}
251 echo 'Section "Screen"' >> ${xfconfig}
252 echo ' Identifier "Screen 1"' >> ${xfconfig}
253 echo ' Device "vga0"' >> ${xfconfig}
254 echo ' Monitor "Monitor0"' >> ${xfconfig}
255 echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}
256 echo ' Subsection "Display"' >> ${xfconfig}
257 echo " Depth ${ALX_DEPTH}" >> ${xfconfig}
258 echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig}
259 echo ' ViewPort 0 0' >> ${xfconfig}
260 echo ' EndSubsection' >> ${xfconfig}
261
262 if [[ ${HAS_REALVNC} = yes ]] || [[ ${HAS_TIGERVNC} = yes ]]
263 then
264 echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
265 echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
266 echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
267 fi
268 echo 'EndSection' >> ${xfconfig}
269
270 # server layout
271 echo '' >> ${xfconfig}
272 echo 'Section "ServerLayout"' >> ${xfconfig}
273 echo ' Identifier "Simple Layout"' >> ${xfconfig}
274 echo ' Screen "Screen 1"' >> ${xfconfig}
275 echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
276 echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
277
278 # load vnc keyboard && mouse
279 if [[ ${HAS_VNC} = yes ]]
280 then
281 echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig}
282 echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}
283 fi
284
285 echo 'EndSection' >> ${xfconfig}
286
287 # dri
288 echo '' >> ${xfconfig}
289 echo 'Section "DRI"' >> ${xfconfig}
290 echo ' Mode 0666' >> ${xfconfig}
291 echo 'EndSection' >> ${xfconfig}
292 }
293