1 | #! /bin/sh
|
---|
2 | #
|
---|
3 | # Linux Additions X11 setup init script ($Revision: 58647 $)
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2012 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 |
|
---|
19 | # chkconfig: 35 30 70
|
---|
20 | # description: VirtualBox Linux Additions kernel modules
|
---|
21 | #
|
---|
22 | ### BEGIN INIT INFO
|
---|
23 | # Provides: vboxadd-x11
|
---|
24 | # Required-Start:
|
---|
25 | # Required-Stop:
|
---|
26 | # Default-Start:
|
---|
27 | # Default-Stop:
|
---|
28 | # Description: VirtualBox Linux Additions X11 setup
|
---|
29 | ### END INIT INFO
|
---|
30 |
|
---|
31 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
32 | LOG="/var/log/vboxadd-install-x11.log"
|
---|
33 | CONFIG_DIR="/var/lib/VBoxGuestAdditions"
|
---|
34 | CONFIG="config"
|
---|
35 | SCRIPTNAME=vboxadd-x11.sh
|
---|
36 |
|
---|
37 | # Check architecture
|
---|
38 | cpu=`uname -m`;
|
---|
39 | case "$cpu" in
|
---|
40 | i[3456789]86|x86)
|
---|
41 | cpu="x86"
|
---|
42 | lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"
|
---|
43 | ;;
|
---|
44 | x86_64|amd64)
|
---|
45 | cpu="amd64"
|
---|
46 | lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"
|
---|
47 | ;;
|
---|
48 | esac
|
---|
49 | for i in $lib_candidates; do
|
---|
50 | if test -d "$i/VBoxGuestAdditions"; then
|
---|
51 | LIB=$i
|
---|
52 | break
|
---|
53 | fi
|
---|
54 | done
|
---|
55 |
|
---|
56 | # Find the version of X installed
|
---|
57 | # The last of the three is for the X.org 6.7 included in Fedora Core 2
|
---|
58 | xver=`X -version 2>&1`
|
---|
59 | x_version=`echo "$xver" | sed -n 's/^X Window System Version \([0-9.]\+\)/\1/p'``echo "$xver" | sed -n 's/^XFree86 Version \([0-9.]\+\)/\1/p'``echo "$xver" | sed -n 's/^X Protocol Version 11, Revision 0, Release \([0-9.]\+\)/\1/p'``echo "$xver" | sed -n 's/^X.Org X Server \([0-9.]\+\)/\1/p'`
|
---|
60 | x_version_short=`echo "${x_version}" | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/'`
|
---|
61 | # Version of Redhat or Fedora installed. Needed for setting up selinux policy.
|
---|
62 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
---|
63 | # All the different possible locations for XFree86/X.Org configuration files
|
---|
64 | # - how many of these have ever been used?
|
---|
65 | x11conf_files="/etc/X11/xorg.conf /etc/X11/xorg.conf-4 /etc/X11/.xorg.conf \
|
---|
66 | /etc/xorg.conf /usr/etc/X11/xorg.conf-4 /usr/etc/X11/xorg.conf \
|
---|
67 | /usr/lib/X11/xorg.conf-4 /usr/lib/X11/xorg.conf /etc/X11/XF86Config-4 \
|
---|
68 | /etc/X11/XF86Config /etc/XF86Config /usr/X11R6/etc/X11/XF86Config-4 \
|
---|
69 | /usr/X11R6/etc/X11/XF86Config /usr/X11R6/lib/X11/XF86Config-4 \
|
---|
70 | /usr/X11R6/lib/X11/XF86Config"
|
---|
71 |
|
---|
72 | # Preamble for Gentoo
|
---|
73 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
74 | shift
|
---|
75 | fi
|
---|
76 |
|
---|
77 | begin()
|
---|
78 | {
|
---|
79 | test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
|
---|
80 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
81 | }
|
---|
82 |
|
---|
83 | succ_msg()
|
---|
84 | {
|
---|
85 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
86 | }
|
---|
87 |
|
---|
88 | fail_msg()
|
---|
89 | {
|
---|
90 | echo "${SCRIPTNAME}: ${1}." >&2
|
---|
91 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
92 | }
|
---|
93 |
|
---|
94 | dev=/dev/vboxguest
|
---|
95 | userdev=/dev/vboxuser
|
---|
96 | owner=vboxadd
|
---|
97 | group=1
|
---|
98 |
|
---|
99 | fail()
|
---|
100 | {
|
---|
101 | echo "${SCRIPTNAME}: failed: ${1}." >&2
|
---|
102 | logger "${SCRIPTNAME}: ${1}."
|
---|
103 | exit 1
|
---|
104 | }
|
---|
105 |
|
---|
106 | # Install an X11 desktop startup application. The application should be a shell script.
|
---|
107 | # Its name should be purely alphanumeric and should start with a two digit number (preferably
|
---|
108 | # 98 or thereabouts) to indicate its place in the Debian Xsession startup order.
|
---|
109 | #
|
---|
110 | # syntax: install_x11_startup_app app desktop service_name
|
---|
111 | install_x11_startup_app() {
|
---|
112 | self="install_x11_startup_app"
|
---|
113 | app_src=$1
|
---|
114 | desktop_src=$2
|
---|
115 | service_name=$3
|
---|
116 | alt_command=$4
|
---|
117 | test -r "$app_src" ||
|
---|
118 | { echo >> $LOG "$self: no script given"; return 1; }
|
---|
119 | test -r "$desktop_src" ||
|
---|
120 | { echo >> $LOG "$self: no desktop file given"; return 1; }
|
---|
121 | test -n "$service_name" ||
|
---|
122 | { echo >> $LOG "$self: no service given"; return 1; }
|
---|
123 | test -n "$alt_command" ||
|
---|
124 | { echo >> $LOG "$self: no service given"; return 1; }
|
---|
125 | app_dest=`basename $app_src sh`
|
---|
126 | app_dest_sh=`basename $app_src sh`.sh
|
---|
127 | desktop_dest=`basename $desktop_src`
|
---|
128 | found=0
|
---|
129 | x11_autostart="/etc/xdg/autostart"
|
---|
130 | kde_autostart="/usr/share/autostart"
|
---|
131 | redhat_dir=/etc/X11/Xsession.d
|
---|
132 | mandriva_dir=/etc/X11/xinit.d
|
---|
133 | debian_dir=/etc/X11/xinit/xinitrc.d
|
---|
134 | if [ -d "$mandriva_dir" -a -w "$mandriva_dir" -a -x "$mandriva_dir" ]
|
---|
135 | then
|
---|
136 | install -m 0644 $app_src "$mandriva_dir/$app_dest"
|
---|
137 | found=1
|
---|
138 | fi
|
---|
139 | if [ -d "$x11_autostart" -a -w "$x11_autostart" -a -x "$x11_autostart" ]
|
---|
140 | then
|
---|
141 | install -m 0644 $desktop_src "$x11_autostart/$desktop_dest"
|
---|
142 | found=1
|
---|
143 | fi
|
---|
144 | if [ -d "$kde_autostart" -a -w "$kde_autostart" -a -x "$kde_autostart" ]
|
---|
145 | then
|
---|
146 | install -m 0644 $desktop_src "$kde_autostart/$desktop_dest"
|
---|
147 | found=1
|
---|
148 | fi
|
---|
149 | if [ -d "$redhat_dir" -a -w "$redhat_dir" -a -x "$redhat_dir" ]
|
---|
150 | then
|
---|
151 | install -m 0644 $app_src "$redhat_dir/$app_dest"
|
---|
152 | found=1
|
---|
153 | fi
|
---|
154 | if [ -d "$debian_dir" -a -w "$debian_dir" -a -x "$debian_dir" ]
|
---|
155 | then
|
---|
156 | install -m 0755 $app_src "$debian_dir/$app_dest_sh"
|
---|
157 | found=1
|
---|
158 | fi
|
---|
159 | if [ $found -eq 1 ]; then
|
---|
160 | return 0
|
---|
161 | fi
|
---|
162 | cat >> $LOG << EOF
|
---|
163 | Could not set up the $service_name desktop service.
|
---|
164 | To start it at log-in for a given user, add the command $alt_command
|
---|
165 | to the file .xinitrc in their home directory.
|
---|
166 | EOF
|
---|
167 | return 1
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | start()
|
---|
172 | {
|
---|
173 | # Todo: check configuration and correct it if necessary
|
---|
174 | return 0
|
---|
175 | }
|
---|
176 |
|
---|
177 | stop()
|
---|
178 | {
|
---|
179 | return 0
|
---|
180 | }
|
---|
181 |
|
---|
182 | restart()
|
---|
183 | {
|
---|
184 | stop && start
|
---|
185 | return 0
|
---|
186 | }
|
---|
187 |
|
---|
188 | # setup_script
|
---|
189 | setup()
|
---|
190 | {
|
---|
191 | echo "VirtualBox Guest Additions installation, Window System and desktop setup" > $LOG
|
---|
192 | begin "Installing the Window System drivers"
|
---|
193 | lib_dir="$LIB/VBoxGuestAdditions"
|
---|
194 | share_dir="/usr/share/VBoxGuestAdditions"
|
---|
195 | test -x "$lib_dir" -a -x "$share_dir" ||
|
---|
196 | fail "Invalid Guest Additions configuration found"
|
---|
197 | # By default we want to configure X
|
---|
198 | dox11config="true"
|
---|
199 | # By default, we want to run our xorg.conf setup script
|
---|
200 | setupxorgconf="true"
|
---|
201 | # All but the oldest supported X servers can automatically set up the
|
---|
202 | # keyboard driver.
|
---|
203 | autokeyboard="--autoKeyboard"
|
---|
204 | # On more recent servers our kernel mouse driver will be used
|
---|
205 | # automatically
|
---|
206 | automouse="--autoMouse"
|
---|
207 | # We need to tell our xorg.conf hacking script whether /dev/psaux exists
|
---|
208 | nopsaux="--nopsaux"
|
---|
209 | case "`uname -r`" in 2.4.*)
|
---|
210 | test -c /dev/psaux && nopsaux="";;
|
---|
211 | esac
|
---|
212 | # Should we use the VMSVGA driver instead of VBoxVideo?
|
---|
213 | if grep 80eebeef /proc/bus/pci/devices > /dev/null; then
|
---|
214 | vmsvga=""
|
---|
215 | elif grep 15ad0405 /proc/bus/pci/devices > /dev/null; then
|
---|
216 | vmsvga="--vmsvga"
|
---|
217 | else
|
---|
218 | dox11config=""
|
---|
219 | fi
|
---|
220 | # The video driver to install for X.Org 6.9+
|
---|
221 | vboxvideo_src=
|
---|
222 | # The mouse driver to install for X.Org 6.9+
|
---|
223 | vboxmouse_src=
|
---|
224 | # The driver extension
|
---|
225 | driver_ext=".so"
|
---|
226 | # The configuration file we generate if no original was found but we need
|
---|
227 | # one.
|
---|
228 | main_cfg="/etc/X11/xorg.conf"
|
---|
229 |
|
---|
230 | modules_dir=`X -showDefaultModulePath 2>&1` || modules_dir=
|
---|
231 | if [ -z "$modules_dir" ]; then
|
---|
232 | for dir in /usr/lib64/xorg/modules /usr/lib/xorg/modules /usr/X11R6/lib64/modules /usr/X11R6/lib/modules /usr/X11R6/lib/X11/modules; do
|
---|
233 | if [ -d $dir ]; then
|
---|
234 | modules_dir=$dir
|
---|
235 | break
|
---|
236 | fi
|
---|
237 | done
|
---|
238 | fi
|
---|
239 |
|
---|
240 | test -z "$x_version" -o -z "$modules_dir" &&
|
---|
241 | {
|
---|
242 | echo
|
---|
243 | echo "Could not find the X.Org or XFree86 Window System, skipping."
|
---|
244 | exit 0
|
---|
245 | }
|
---|
246 |
|
---|
247 | echo
|
---|
248 | # openSUSE 10.3 shipped X.Org 7.2 with X.Org Server 1.3, but didn't
|
---|
249 | # advertise the fact.
|
---|
250 | if grep -q '10\.3' /etc/SuSE-release 2>/dev/null; then
|
---|
251 | case $x_version in 7.2.*)
|
---|
252 | x_version=1.3.0;;
|
---|
253 | esac
|
---|
254 | fi
|
---|
255 | case $x_version in
|
---|
256 | 1.17.99.902* )
|
---|
257 | # special case for Fedora 23 :-/
|
---|
258 | x_version_short="1.18"
|
---|
259 | xserver_version="X.Org Server ${x_version_short}"
|
---|
260 | vboxvideo_src=vboxvideo_drv_`echo ${x_version_short} | sed 's/\.//'`.so
|
---|
261 | setupxorgconf=""
|
---|
262 | test -f "${lib_dir}/${vboxvideo_src}" ||
|
---|
263 | {
|
---|
264 | echo "Warning: unknown version of the X Window System installed. Not installing"
|
---|
265 | echo "X Window System drivers."
|
---|
266 | dox11config=""
|
---|
267 | vboxvideo_src=""
|
---|
268 | }
|
---|
269 | ;;
|
---|
270 | 1.*.99.* )
|
---|
271 | echo "Warning: unsupported pre-release version of X.Org Server installed. Not"
|
---|
272 | echo "installing the X.Org drivers."
|
---|
273 | dox11config=""
|
---|
274 | ;;
|
---|
275 | 1.11.* )
|
---|
276 | xserver_version="X.Org Server 1.11"
|
---|
277 | vboxvideo_src=vboxvideo_drv_111.so
|
---|
278 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
279 | ;;
|
---|
280 | 1.10.* )
|
---|
281 | xserver_version="X.Org Server 1.10"
|
---|
282 | vboxvideo_src=vboxvideo_drv_110.so
|
---|
283 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
284 | ;;
|
---|
285 | 1.9.* )
|
---|
286 | xserver_version="X.Org Server 1.9"
|
---|
287 | vboxvideo_src=vboxvideo_drv_19.so
|
---|
288 | # Fedora 14 to 16 patched out vboxvideo detection
|
---|
289 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
290 | ;;
|
---|
291 | 1.8.* )
|
---|
292 | xserver_version="X.Org Server 1.8"
|
---|
293 | vboxvideo_src=vboxvideo_drv_18.so
|
---|
294 | # Fedora 13 shipped without vboxvideo detection
|
---|
295 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
296 | ;;
|
---|
297 | 1.7.* )
|
---|
298 | xserver_version="X.Org Server 1.7"
|
---|
299 | vboxvideo_src=vboxvideo_drv_17.so
|
---|
300 | setupxorgconf=""
|
---|
301 | ;;
|
---|
302 | 1.6.* )
|
---|
303 | xserver_version="X.Org Server 1.6"
|
---|
304 | vboxvideo_src=vboxvideo_drv_16.so
|
---|
305 | vboxmouse_src=vboxmouse_drv_16.so
|
---|
306 | # SUSE SLE* with X.Org 1.6 does not do input autodetection;
|
---|
307 | # openSUSE does.
|
---|
308 | if grep -q -E '^SLE[^ ]' /etc/SuSE-brand 2>/dev/null; then
|
---|
309 | automouse=""
|
---|
310 | else
|
---|
311 | test "$system" = "suse" && setupxorgconf=""
|
---|
312 | fi
|
---|
313 | ;;
|
---|
314 | 1.5.* )
|
---|
315 | xserver_version="X.Org Server 1.5"
|
---|
316 | vboxvideo_src=vboxvideo_drv_15.so
|
---|
317 | vboxmouse_src=vboxmouse_drv_15.so
|
---|
318 | # Historical note: SUSE with X.Org Server 1.5 disabled automatic
|
---|
319 | # mouse configuration and was handled specially. However since our
|
---|
320 | # kernel driver seems to have problems with X.Org Server 1.5 anyway
|
---|
321 | # we just create an X.Org configuration file and use the user space
|
---|
322 | # one generally, no longer just for SUSE.
|
---|
323 | automouse=""
|
---|
324 | ;;
|
---|
325 | 1.4.* )
|
---|
326 | xserver_version="X.Org Server 1.4"
|
---|
327 | vboxvideo_src=vboxvideo_drv_14.so
|
---|
328 | vboxmouse_src=vboxmouse_drv_14.so
|
---|
329 | automouse=""
|
---|
330 | ;;
|
---|
331 | 1.3.* )
|
---|
332 | # This was the first release which gave the server version number
|
---|
333 | # rather than the X11 release version when you did 'X -version'.
|
---|
334 | xserver_version="X.Org Server 1.3"
|
---|
335 | vboxvideo_src=vboxvideo_drv_13.so
|
---|
336 | vboxmouse_src=vboxmouse_drv_13.so
|
---|
337 | automouse=""
|
---|
338 | ;;
|
---|
339 | 7.1.* | 7.2.* )
|
---|
340 | xserver_version="X.Org 7.1"
|
---|
341 | vboxvideo_src=vboxvideo_drv_71.so
|
---|
342 | vboxmouse_src=vboxmouse_drv_71.so
|
---|
343 | automouse=""
|
---|
344 | ;;
|
---|
345 | 6.9.* | 7.0.* )
|
---|
346 | xserver_version="X.Org 6.9/7.0"
|
---|
347 | vboxvideo_src=vboxvideo_drv_70.so
|
---|
348 | vboxmouse_src=vboxmouse_drv_70.so
|
---|
349 | automouse=""
|
---|
350 | ;;
|
---|
351 | 6.7* | 6.8.* | 4.2.* | 4.3.* )
|
---|
352 | # As the module binaries are the same we use one text for these
|
---|
353 | # four server versions.
|
---|
354 | xserver_version="XFree86 4.2/4.3 and X.Org 6.7/6.8"
|
---|
355 | driver_ext=.o
|
---|
356 | vboxvideo_src=vboxvideo_drv.o
|
---|
357 | vboxmouse_src=vboxmouse_drv.o
|
---|
358 | automouse=""
|
---|
359 | autokeyboard=""
|
---|
360 | case $x_version in
|
---|
361 | 6.8.* )
|
---|
362 | autokeyboard="true"
|
---|
363 | ;;
|
---|
364 | 4.2.* | 4.3.* )
|
---|
365 | main_cfg="/etc/X11/XF86Config"
|
---|
366 | ;;
|
---|
367 | esac
|
---|
368 | ;;
|
---|
369 | * )
|
---|
370 | # Anything else, including all X server versions as of 1.12.
|
---|
371 | xserver_version="X.Org Server ${x_version_short}"
|
---|
372 | vboxvideo_src=vboxvideo_drv_`echo ${x_version_short} | sed 's/\.//'`.so
|
---|
373 | setupxorgconf=""
|
---|
374 | test -f "${lib_dir}/${vboxvideo_src}" ||
|
---|
375 | {
|
---|
376 | echo "Warning: unknown version of the X Window System installed. Not installing"
|
---|
377 | echo "X Window System drivers."
|
---|
378 | dox11config=""
|
---|
379 | vboxvideo_src=""
|
---|
380 | }
|
---|
381 | ;;
|
---|
382 | esac
|
---|
383 | test -n "${dox11config}" &&
|
---|
384 | begin "Installing $xserver_version modules"
|
---|
385 | rm "$modules_dir/drivers/vboxvideo_drv$driver_ext" 2>/dev/null
|
---|
386 | rm "$modules_dir/input/vboxmouse_drv$driver_ext" 2>/dev/null
|
---|
387 | case "$vboxvideo_src" in ?*)
|
---|
388 | ln -s "$lib_dir/$vboxvideo_src" "$modules_dir/drivers/vboxvideo_drv$driver_ext";;
|
---|
389 | esac
|
---|
390 | case "$vboxmouse_src" in ?*)
|
---|
391 | ln -s "$lib_dir/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv$driver_ext";;
|
---|
392 | esac
|
---|
393 | succ_msg "$xserver_version modules installed"
|
---|
394 |
|
---|
395 | if test -n "$dox11config"; then
|
---|
396 | begin "Setting up the Window System to use the Guest Additions"
|
---|
397 | # Certain Ubuntu/Debian versions use a special PCI-id file to identify
|
---|
398 | # video drivers. Some versions have the directory and don't use it.
|
---|
399 | # Those versions can autoload vboxvideo though, so we don't need to
|
---|
400 | # hack the configuration file for them.
|
---|
401 | test "$system" = "debian" -a -d /usr/share/xserver-xorg/pci &&
|
---|
402 | {
|
---|
403 | rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
|
---|
404 | ln -s "$share_dir/vboxvideo.ids" /usr/share/xserver-xorg/pci 2>/dev/null
|
---|
405 | test -n "$automouse" && setupxorgconf=""
|
---|
406 | }
|
---|
407 |
|
---|
408 | # Do the XF86Config/xorg.conf hack for those versions that require it
|
---|
409 | configured=""
|
---|
410 | generated=""
|
---|
411 | if test -n "$setupxorgconf"; then
|
---|
412 | for i in $x11conf_files; do
|
---|
413 | if test -r "$i"; then
|
---|
414 | if grep -q "VirtualBox generated" "$i"; then
|
---|
415 | generated="$generated `printf "$i\n"`"
|
---|
416 | else
|
---|
417 | "$lib_dir/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga "$i"
|
---|
418 | fi
|
---|
419 | configured="true"
|
---|
420 | fi
|
---|
421 | # Timestamp, so that we can see if the config file is changed
|
---|
422 | # by someone else later
|
---|
423 | test -r "$i.vbox" && touch "$i.vbox"
|
---|
424 | done
|
---|
425 | # X.Org Server 1.5 and 1.6 can detect hardware they know, but they
|
---|
426 | # need a configuration file for VBoxVideo.
|
---|
427 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
428 | if test -z "$configured"; then
|
---|
429 | touch "$main_cfg"
|
---|
430 | "$lib_dir/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga --noBak "$main_cfg"
|
---|
431 | touch "${nobak_cfg}"
|
---|
432 | fi
|
---|
433 | fi
|
---|
434 | succ_msg "Window System set up to use the Guest Additions"
|
---|
435 | test -n "$generated" &&
|
---|
436 | cat << EOF
|
---|
437 | The following X.Org/XFree86 configuration files were originally generated by
|
---|
438 | the VirtualBox Guest Additions and were not modified:
|
---|
439 |
|
---|
440 | $generated
|
---|
441 |
|
---|
442 | EOF
|
---|
443 | cat << EOF
|
---|
444 | You may need to restart the the Window System (or just restart the guest system)
|
---|
445 | to enable the Guest Additions.
|
---|
446 |
|
---|
447 | EOF
|
---|
448 | fi
|
---|
449 |
|
---|
450 | begin "Installing graphics libraries and desktop services components"
|
---|
451 | case "$redhat_release" in
|
---|
452 | # Install selinux policy for Fedora 7 and 8 to allow the X server to
|
---|
453 | # open device files
|
---|
454 | Fedora\ release\ 7* | Fedora\ release\ 8* )
|
---|
455 | semodule -i "$share_dir/vbox_x11.pp" > /dev/null 2>&1
|
---|
456 | ;;
|
---|
457 | # Similar for the accelerated graphics check on Fedora 15
|
---|
458 | Fedora\ release\ 15* )
|
---|
459 | semodule -i "$share_dir/vbox_accel.pp" > /dev/null 2>&1
|
---|
460 | ;;
|
---|
461 | esac
|
---|
462 |
|
---|
463 | # Install selinux policy for Fedora 8 to allow the X server to
|
---|
464 | # open our drivers
|
---|
465 | case "$redhat_release" in
|
---|
466 | Fedora\ release\ 8* )
|
---|
467 | chcon -u system_u -t lib_t "$lib_dir"/*.so
|
---|
468 | ;;
|
---|
469 | esac
|
---|
470 |
|
---|
471 | # Our logging code generates some glue code on 32-bit systems. At least F10
|
---|
472 | # needs a rule to allow this. Send all output to /dev/null in case this is
|
---|
473 | # completely irrelevant on the target system.
|
---|
474 | chcon -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
---|
475 | semanage fcontext -a -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
---|
476 | # Install the guest OpenGL drivers. For now we don't support
|
---|
477 | # multi-architecture installations
|
---|
478 | for dir in /usr/lib/dri /usr/lib32/dri /usr/lib64/dri \
|
---|
479 | /usr/lib/xorg/modules/dri /usr/lib32/xorg/modules/dri \
|
---|
480 | /usr/lib64/xorg/modules/dri /usr/lib/i386-linux-gnu/dri \
|
---|
481 | /usr/lib/x86_64-linux-gnu/dri; do
|
---|
482 | if [ -d $dir ]; then
|
---|
483 | rm -f "$dir/vboxvideo_dri.so"
|
---|
484 | ln -s "$LIB/VBoxOGL.so" "$dir/vboxvideo_dri.so"
|
---|
485 | fi
|
---|
486 | done
|
---|
487 |
|
---|
488 | # And set up VBoxClient to start when the X session does
|
---|
489 | install_x11_startup_app "$lib_dir/98vboxadd-xclient" "$share_dir/vboxclient.desktop" VBoxClient VBoxClient-all ||
|
---|
490 | fail "See the log file $LOG for more information."
|
---|
491 | ln -s "$lib_dir/98vboxadd-xclient" /usr/bin/VBoxClient-all 2>/dev/null
|
---|
492 | succ_msg "Window system drivers installed"
|
---|
493 | }
|
---|
494 |
|
---|
495 | # cleanup_script
|
---|
496 | cleanup()
|
---|
497 | {
|
---|
498 | # Restore xorg.conf files as far as possible
|
---|
499 | # List of generated files which have been changed since we generated them
|
---|
500 | newer=""
|
---|
501 | # Are we dealing with a legacy information which didn't support
|
---|
502 | # uninstallation?
|
---|
503 | legacy=""
|
---|
504 | # Do any of the restored configuration files still reference our drivers?
|
---|
505 | failed=""
|
---|
506 | # Have we encountered a "nobak" configuration file which means that there
|
---|
507 | # is no original file to restore?
|
---|
508 | nobak=""
|
---|
509 | test -r "$CONFIG_DIR/$CONFIG" || legacy="true"
|
---|
510 | for main_cfg in "/etc/X11/xorg.conf" "/etc/X11/XF86Config"; do
|
---|
511 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
512 | if test -r "${nobak_cfg}"; then
|
---|
513 | test -r "${main_cfg}" &&
|
---|
514 | if test -n "${legacy}" -o ! "${nobak_cfg}" -ot "${main_cfg}"; then
|
---|
515 | rm -f "${nobak_cfg}" "${main_cfg}"
|
---|
516 | else
|
---|
517 | newer="${newer}`printf " ${main_cfg} (no original)\n"`"
|
---|
518 | fi
|
---|
519 | nobak="true"
|
---|
520 | fi
|
---|
521 | done
|
---|
522 | if test -z "${nobak}"; then
|
---|
523 | for i in $x11conf_files; do
|
---|
524 | if test -r "$i.vbox"; then
|
---|
525 | if test ! "$i" -nt "$i.vbox" -o -n "$legacy"; then
|
---|
526 | mv -f "$i.vbox" "$i"
|
---|
527 | grep -q -E 'vboxvideo|vboxmouse' "$i" &&
|
---|
528 | failed="$failed`printf " $i\n"`"
|
---|
529 | else
|
---|
530 | newer="$newer`printf " $i ($i.vbox)\n"`"
|
---|
531 | fi
|
---|
532 | fi
|
---|
533 | done
|
---|
534 | fi
|
---|
535 | test -n "$newer" && cat << EOF
|
---|
536 |
|
---|
537 | The following X.Org/XFree86 configuration files were not restored, as they may
|
---|
538 | have been changed since they were generated by the VirtualBox Guest Additions.
|
---|
539 | You may wish to restore these manually. The file name in brackets is the
|
---|
540 | original version.
|
---|
541 |
|
---|
542 | $newer
|
---|
543 |
|
---|
544 | EOF
|
---|
545 | test -n "$failed" && cat << EOF
|
---|
546 |
|
---|
547 | The following X.Org/XFree86 configuration files were restored, but still
|
---|
548 | contain references to the Guest Additions drivers. You may wish to check and
|
---|
549 | possibly correct the restored configuration files to be sure that the server
|
---|
550 | will continue to work after it is restarted.
|
---|
551 |
|
---|
552 | $failed
|
---|
553 |
|
---|
554 | EOF
|
---|
555 |
|
---|
556 | # Remove X.Org drivers
|
---|
557 | modules_dir=`X -showDefaultModulePath 2>&1` || modules_dir=
|
---|
558 | if [ -z "$modules_dir" ]; then
|
---|
559 | for dir in /usr/lib64/xorg/modules /usr/lib/xorg/modules /usr/X11R6/lib64/modules /usr/X11R6/lib/modules /usr/X11R6/lib/X11/modules; do
|
---|
560 | if [ -d $dir ]; then
|
---|
561 | modules_dir=$dir
|
---|
562 | break
|
---|
563 | fi
|
---|
564 | done
|
---|
565 | fi
|
---|
566 | rm -f "$modules_dir/drivers/vboxvideo_drv"* 2>/dev/null
|
---|
567 | rm -f "$modules_dir/input/vboxmouse_drv"* 2>/dev/null
|
---|
568 |
|
---|
569 | # Remove the link to vboxvideo_dri.so
|
---|
570 | for dir in /usr/lib/dri /usr/lib32/dri /usr/lib64/dri \
|
---|
571 | /usr/lib/xorg/modules/dri /usr/lib32/xorg/modules/dri \
|
---|
572 | /usr/lib64/xorg/modules/dri /usr/lib/i386-linux-gnu/dri \
|
---|
573 | /usr/lib/x86_64-linux-gnu/dri; do
|
---|
574 | if [ -d $dir ]; then
|
---|
575 | rm -f "$dir/vboxvideo_dri.so" 2>/dev/null
|
---|
576 | fi
|
---|
577 | done
|
---|
578 |
|
---|
579 | # Remove VBoxClient autostart files
|
---|
580 | rm /etc/X11/Xsession.d/98vboxadd-xclient 2>/dev/null
|
---|
581 | rm /etc/X11/xinit.d/98vboxadd-xclient 2>/dev/null
|
---|
582 | rm /etc/X11/xinit/xinitrc.d/98vboxadd-xclient.sh 2>/dev/null
|
---|
583 | rm /etc/xdg/autostart/vboxclient.desktop 2>/dev/null
|
---|
584 | rm /usr/share/autostart/vboxclient.desktop 2>/dev/null
|
---|
585 | rm /usr/bin/VBoxClient-all 2>/dev/null
|
---|
586 |
|
---|
587 | # Remove other files
|
---|
588 | rm /usr/share/xserver-xorg/pci/vboxvideo.ids 2>/dev/null
|
---|
589 | }
|
---|
590 |
|
---|
591 | dmnstatus()
|
---|
592 | {
|
---|
593 | /bin/true
|
---|
594 | }
|
---|
595 |
|
---|
596 | case "$1" in
|
---|
597 | start)
|
---|
598 | start
|
---|
599 | ;;
|
---|
600 | stop)
|
---|
601 | stop
|
---|
602 | ;;
|
---|
603 | restart)
|
---|
604 | restart
|
---|
605 | ;;
|
---|
606 | setup)
|
---|
607 | setup
|
---|
608 | ;;
|
---|
609 | cleanup)
|
---|
610 | cleanup
|
---|
611 | ;;
|
---|
612 | status)
|
---|
613 | dmnstatus
|
---|
614 | ;;
|
---|
615 | *)
|
---|
616 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
617 | exit 1
|
---|
618 | esac
|
---|
619 |
|
---|
620 | exit
|
---|