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