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