[24410] | 1 | #! /bin/sh
|
---|
[69327] | 2 | # $Id: vboxadd-x11.sh 93115 2022-01-01 11:31:46Z vboxsync $
|
---|
| 3 | ## @file
|
---|
[24410] | 4 | # Linux Additions X11 setup init script ($Revision: 93115 $)
|
---|
| 5 | #
|
---|
| 6 |
|
---|
| 7 | #
|
---|
[93115] | 8 | # Copyright (C) 2006-2022 Oracle Corporation
|
---|
[24410] | 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
|
---|
[24651] | 33 | CONFIG_DIR="/var/lib/VBoxGuestAdditions"
|
---|
[63889] | 34 | CONFIG="${CONFIG_DIR}/config"
|
---|
[59199] | 35 | MODPROBE=/sbin/modprobe
|
---|
[24410] | 36 |
|
---|
[59199] | 37 | if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules *0'; then
|
---|
| 38 | MODPROBE="$MODPROBE --allow-unsupported-modules"
|
---|
| 39 | fi
|
---|
| 40 |
|
---|
[24410] | 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'`
|
---|
[45135] | 45 | x_version_short=`echo "${x_version}" | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/'`
|
---|
[24410] | 46 | # Version of Redhat or Fedora installed. Needed for setting up selinux policy.
|
---|
| 47 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
---|
[67658] | 48 | # Version of OL installed. Needed for blacklisting vboxvideo.
|
---|
| 49 | oracle_release=`cat /etc/oracle-release 2> /dev/null`
|
---|
[24410] | 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 |
|
---|
[57945] | 59 | # Preamble for Gentoo
|
---|
| 60 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
| 61 | shift
|
---|
[24410] | 62 | fi
|
---|
| 63 |
|
---|
| 64 | dev=/dev/vboxguest
|
---|
| 65 | userdev=/dev/vboxuser
|
---|
| 66 | owner=vboxadd
|
---|
| 67 | group=1
|
---|
| 68 |
|
---|
| 69 | fail()
|
---|
| 70 | {
|
---|
[63870] | 71 | echo "${1}" >&2
|
---|
[24410] | 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() {
|
---|
[24651] | 81 | self="install_x11_startup_app"
|
---|
[24410] | 82 | app_src=$1
|
---|
| 83 | desktop_src=$2
|
---|
| 84 | service_name=$3
|
---|
| 85 | alt_command=$4
|
---|
[63870] | 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"
|
---|
[24410] | 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
|
---|
[63870] | 127 | cat >&2 << EOF
|
---|
[24651] | 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.
|
---|
[24410] | 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 |
|
---|
[75428] | 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
|
---|
[77049] | 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
|
---|
[75428] | 171 | fi
|
---|
| 172 | echo "/var/lib/VBoxGuestAdditions/lib" > /etc/ld.so.conf.d/00vboxvideo.conf
|
---|
| 173 | fi
|
---|
| 174 | ldconfig
|
---|
| 175 | }
|
---|
| 176 |
|
---|
[24410] | 177 | setup()
|
---|
| 178 | {
|
---|
[63889] | 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"
|
---|
[63890] | 186 | lib_dir="${INSTALL_DIR}/other"
|
---|
| 187 | test -x "${lib_dir}" ||
|
---|
[63870] | 188 | fail "Invalid Guest Additions configuration found."
|
---|
[24651] | 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"
|
---|
[46563] | 193 | # All but the oldest supported X servers can automatically set up the
|
---|
| 194 | # keyboard driver.
|
---|
| 195 | autokeyboard="--autoKeyboard"
|
---|
[38784] | 196 | # On more recent servers our kernel mouse driver will be used
|
---|
| 197 | # automatically
|
---|
[26386] | 198 | automouse="--autoMouse"
|
---|
[25174] | 199 | # We need to tell our xorg.conf hacking script whether /dev/psaux exists
|
---|
| 200 | nopsaux="--nopsaux"
|
---|
[39809] | 201 | case "`uname -r`" in 2.4.*)
|
---|
| 202 | test -c /dev/psaux && nopsaux="";;
|
---|
| 203 | esac
|
---|
[50312] | 204 | # Should we use the VMSVGA driver instead of VBoxVideo?
|
---|
[50499] | 205 | if grep 80eebeef /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 206 | vmsvga=""
|
---|
[50499] | 207 | elif grep 15ad0405 /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 208 | vmsvga="--vmsvga"
|
---|
[50499] | 209 | else
|
---|
| 210 | dox11config=""
|
---|
[50312] | 211 | fi
|
---|
[24410] | 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=
|
---|
[38823] | 216 | # The driver extension
|
---|
| 217 | driver_ext=".so"
|
---|
[46574] | 218 | # The configuration file we generate if no original was found but we need
|
---|
| 219 | # one.
|
---|
| 220 | main_cfg="/etc/X11/xorg.conf"
|
---|
[24410] | 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 |
|
---|
[67858] | 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
|
---|
[68684] | 243 | test -d /etc/modprobe.d &&
|
---|
| 244 | echo "blacklist vboxvideo" > /etc/modprobe.d/blacklist-vboxvideo.conf
|
---|
[67858] | 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 |
|
---|
[24410] | 254 | test -z "$x_version" -o -z "$modules_dir" &&
|
---|
[50107] | 255 | {
|
---|
[63870] | 256 | echo "Could not find the X.Org or XFree86 Window System, skipping." >&2
|
---|
[50107] | 257 | exit 0
|
---|
| 258 | }
|
---|
[24410] | 259 |
|
---|
[35209] | 260 | # openSUSE 10.3 shipped X.Org 7.2 with X.Org Server 1.3, but didn't
|
---|
| 261 | # advertise the fact.
|
---|
[35210] | 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
|
---|
[24410] | 267 | case $x_version in
|
---|
[36388] | 268 | 1.*.99.* )
|
---|
[63870] | 269 | echo "Warning: unsupported pre-release version of X.Org Server installed. Not installing the X.Org drivers." >&2
|
---|
[24651] | 270 | dox11config=""
|
---|
[24410] | 271 | ;;
|
---|
[38826] | 272 | 1.11.* )
|
---|
| 273 | xserver_version="X.Org Server 1.11"
|
---|
| 274 | vboxvideo_src=vboxvideo_drv_111.so
|
---|
[50312] | 275 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[38826] | 276 | ;;
|
---|
[36301] | 277 | 1.10.* )
|
---|
[38823] | 278 | xserver_version="X.Org Server 1.10"
|
---|
[35841] | 279 | vboxvideo_src=vboxvideo_drv_110.so
|
---|
[50312] | 280 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[35841] | 281 | ;;
|
---|
[36388] | 282 | 1.9.* )
|
---|
[38823] | 283 | xserver_version="X.Org Server 1.9"
|
---|
[32166] | 284 | vboxvideo_src=vboxvideo_drv_19.so
|
---|
[44936] | 285 | # Fedora 14 to 16 patched out vboxvideo detection
|
---|
[50312] | 286 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[32166] | 287 | ;;
|
---|
[36388] | 288 | 1.8.* )
|
---|
[38823] | 289 | xserver_version="X.Org Server 1.8"
|
---|
[28064] | 290 | vboxvideo_src=vboxvideo_drv_18.so
|
---|
[32166] | 291 | # Fedora 13 shipped without vboxvideo detection
|
---|
[50312] | 292 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[28064] | 293 | ;;
|
---|
[36388] | 294 | 1.7.* )
|
---|
[38823] | 295 | xserver_version="X.Org Server 1.7"
|
---|
[24410] | 296 | vboxvideo_src=vboxvideo_drv_17.so
|
---|
[24651] | 297 | setupxorgconf=""
|
---|
[24410] | 298 | ;;
|
---|
[36388] | 299 | 1.6.* )
|
---|
[38823] | 300 | xserver_version="X.Org Server 1.6"
|
---|
[24410] | 301 | vboxvideo_src=vboxvideo_drv_16.so
|
---|
| 302 | vboxmouse_src=vboxmouse_drv_16.so
|
---|
[36666] | 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
|
---|
[24410] | 310 | ;;
|
---|
[36388] | 311 | 1.5.* )
|
---|
[38823] | 312 | xserver_version="X.Org Server 1.5"
|
---|
[24410] | 313 | vboxvideo_src=vboxvideo_drv_15.so
|
---|
| 314 | vboxmouse_src=vboxmouse_drv_15.so
|
---|
[49196] | 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=""
|
---|
[24410] | 321 | ;;
|
---|
| 322 | 1.4.* )
|
---|
[38823] | 323 | xserver_version="X.Org Server 1.4"
|
---|
[24410] | 324 | vboxvideo_src=vboxvideo_drv_14.so
|
---|
| 325 | vboxmouse_src=vboxmouse_drv_14.so
|
---|
[26386] | 326 | automouse=""
|
---|
[24410] | 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'.
|
---|
[38823] | 331 | xserver_version="X.Org Server 1.3"
|
---|
[24410] | 332 | vboxvideo_src=vboxvideo_drv_13.so
|
---|
[25084] | 333 | vboxmouse_src=vboxmouse_drv_13.so
|
---|
[26386] | 334 | automouse=""
|
---|
[24410] | 335 | ;;
|
---|
| 336 | 7.1.* | 7.2.* )
|
---|
[38823] | 337 | xserver_version="X.Org 7.1"
|
---|
[24410] | 338 | vboxvideo_src=vboxvideo_drv_71.so
|
---|
| 339 | vboxmouse_src=vboxmouse_drv_71.so
|
---|
[26386] | 340 | automouse=""
|
---|
[24410] | 341 | ;;
|
---|
| 342 | 6.9.* | 7.0.* )
|
---|
[38823] | 343 | xserver_version="X.Org 6.9/7.0"
|
---|
[24410] | 344 | vboxvideo_src=vboxvideo_drv_70.so
|
---|
| 345 | vboxmouse_src=vboxmouse_drv_70.so
|
---|
[26386] | 346 | automouse=""
|
---|
[24410] | 347 | ;;
|
---|
| 348 | 6.7* | 6.8.* | 4.2.* | 4.3.* )
|
---|
[46574] | 349 | # As the module binaries are the same we use one text for these
|
---|
| 350 | # four server versions.
|
---|
[38823] | 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
|
---|
[26386] | 355 | automouse=""
|
---|
[46574] | 356 | autokeyboard=""
|
---|
| 357 | case $x_version in
|
---|
| 358 | 6.8.* )
|
---|
[70937] | 359 | autokeyboard="--autoKeyboard"
|
---|
[46574] | 360 | ;;
|
---|
| 361 | 4.2.* | 4.3.* )
|
---|
| 362 | main_cfg="/etc/X11/XF86Config"
|
---|
| 363 | ;;
|
---|
| 364 | esac
|
---|
[24410] | 365 | ;;
|
---|
[60105] | 366 | 1.12.* | 1.13.* | 1.14.* | 1.15.* | 1.16.* | 1.17.* | 1.18.* )
|
---|
[45135] | 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 | {
|
---|
[63870] | 372 | echo "Warning: unknown version of the X Window System installed. Not installing X Window System drivers." >&2
|
---|
[45135] | 373 | dox11config=""
|
---|
| 374 | vboxvideo_src=""
|
---|
| 375 | }
|
---|
[24410] | 376 | ;;
|
---|
[59199] | 377 | * )
|
---|
| 378 | # For anything else, assume kernel drivers.
|
---|
| 379 | dox11config=""
|
---|
| 380 | ;;
|
---|
[24410] | 381 | esac
|
---|
[45135] | 382 | test -n "${dox11config}" &&
|
---|
[63870] | 383 | echo "Installing $xserver_version modules" >&2
|
---|
[60317] | 384 | case "$vboxvideo_src" in
|
---|
| 385 | ?*)
|
---|
[63890] | 386 | ln -s "${lib_dir}/$vboxvideo_src" "$modules_dir/drivers/vboxvideo_drv$driver_ext.new" &&
|
---|
[60317] | 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
|
---|
[38823] | 390 | esac
|
---|
[60317] | 391 | case "$vboxmouse_src" in
|
---|
| 392 | ?*)
|
---|
[63890] | 393 | ln -s "${lib_dir}/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv$driver_ext.new" &&
|
---|
[60350] | 394 | mv "$modules_dir/input/vboxmouse_drv$driver_ext.new" "$modules_dir/input/vboxmouse_drv$driver_ext";;
|
---|
[60317] | 395 | *)
|
---|
| 396 | rm "$modules_dir/input/vboxmouse_drv$driver_ext" 2>/dev/null
|
---|
[38823] | 397 | esac
|
---|
[24651] | 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.
|
---|
[26386] | 404 | test "$system" = "debian" -a -d /usr/share/xserver-xorg/pci &&
|
---|
[24651] | 405 | {
|
---|
| 406 | rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
|
---|
[63890] | 407 | ln -s "${lib_dir}/vboxvideo.ids" /usr/share/xserver-xorg/pci 2>/dev/null
|
---|
[26386] | 408 | test -n "$automouse" && setupxorgconf=""
|
---|
[24651] | 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
|
---|
[63890] | 420 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga "$i"
|
---|
[24651] | 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.
|
---|
[46574] | 430 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
[26531] | 431 | if test -z "$configured"; then
|
---|
[24651] | 432 | touch "$main_cfg"
|
---|
[63890] | 433 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga --noBak "$main_cfg"
|
---|
[46574] | 434 | touch "${nobak_cfg}"
|
---|
[24651] | 435 | fi
|
---|
| 436 | fi
|
---|
| 437 | test -n "$generated" &&
|
---|
[63870] | 438 | cat >&2 << EOF
|
---|
[24651] | 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
|
---|
[63870] | 445 | tty >/dev/null && cat << EOF
|
---|
[64525] | 446 | You may need to restart the Window System (or just restart the guest system)
|
---|
[49196] | 447 | to enable the Guest Additions.
|
---|
[24739] | 448 |
|
---|
| 449 | EOF
|
---|
[24651] | 450 | fi
|
---|
| 451 |
|
---|
[24410] | 452 | case "$redhat_release" in
|
---|
[37104] | 453 | # Install selinux policy for Fedora 7 and 8 to allow the X server to
|
---|
| 454 | # open device files
|
---|
[24410] | 455 | Fedora\ release\ 7* | Fedora\ release\ 8* )
|
---|
[63890] | 456 | semodule -i "${lib_dir}/vbox_x11.pp" > /dev/null 2>&1
|
---|
[24410] | 457 | ;;
|
---|
[37104] | 458 | # Similar for the accelerated graphics check on Fedora 15
|
---|
| 459 | Fedora\ release\ 15* )
|
---|
[63890] | 460 | semodule -i "${lib_dir}/vbox_accel.pp" > /dev/null 2>&1
|
---|
[37104] | 461 | ;;
|
---|
[24410] | 462 | esac
|
---|
| 463 |
|
---|
[25081] | 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* )
|
---|
[77049] | 468 | chcon -u system_u -t lib_t "${lib_dir}"/*.so 2>/dev/null
|
---|
[25081] | 469 | ;;
|
---|
| 470 | esac
|
---|
| 471 |
|
---|
[24410] | 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.
|
---|
[77049] | 475 | # chcon is needed on old Fedora/Redhat systems. No one remembers which.
|
---|
[24410] | 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
|
---|
[63890] | 480 | install_x11_startup_app "${lib_dir}/98vboxadd-xclient" "${lib_dir}/vboxclient.desktop" VBoxClient VBoxClient-all ||
|
---|
[68705] | 481 | fail "Failed to set up VBoxClient to start automatically."
|
---|
[63890] | 482 | ln -s "${lib_dir}/98vboxadd-xclient" /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[75428] | 483 | case "${x_version}" in 4.* | 6.* | 7.* | 1.?.* | 1.1* )
|
---|
| 484 | setup_opengl
|
---|
[75439] | 485 | esac
|
---|
[75837] | 486 | # Try enabling VMSVGA drm device resizing.
|
---|
[83249] | 487 | #VBoxClient --vmsvga
|
---|
[24410] | 488 | }
|
---|
| 489 |
|
---|
| 490 | cleanup()
|
---|
| 491 | {
|
---|
| 492 | # Restore xorg.conf files as far as possible
|
---|
[46574] | 493 | # List of generated files which have been changed since we generated them
|
---|
[24651] | 494 | newer=""
|
---|
[46574] | 495 | # Are we dealing with a legacy information which didn't support
|
---|
[24651] | 496 | # uninstallation?
|
---|
| 497 | legacy=""
|
---|
[46574] | 498 | # Do any of the restored configuration files still reference our drivers?
|
---|
[24651] | 499 | failed=""
|
---|
[46574] | 500 | # Have we encountered a "nobak" configuration file which means that there
|
---|
| 501 | # is no original file to restore?
|
---|
| 502 | nobak=""
|
---|
[24651] | 503 | test -r "$CONFIG_DIR/$CONFIG" || legacy="true"
|
---|
[46574] | 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}"
|
---|
[24651] | 510 | else
|
---|
[46574] | 511 | newer="${newer}`printf " ${main_cfg} (no original)\n"`"
|
---|
[24410] | 512 | fi
|
---|
[46574] | 513 | nobak="true"
|
---|
| 514 | fi
|
---|
| 515 | done
|
---|
[56776] | 516 | if test -z "${nobak}"; then
|
---|
[24651] | 517 | for i in $x11conf_files; do
|
---|
| 518 | if test -r "$i.vbox"; then
|
---|
[25174] | 519 | if test ! "$i" -nt "$i.vbox" -o -n "$legacy"; then
|
---|
[24651] | 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
|
---|
[24410] | 526 | fi
|
---|
[24651] | 527 | done
|
---|
| 528 | fi
|
---|
[63870] | 529 | test -n "$newer" && cat >&2 << EOF
|
---|
[24651] | 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 |
|
---|
[24410] | 538 | EOF
|
---|
[63870] | 539 | test -n "$failed" && cat >&2 << EOF
|
---|
[24410] | 540 |
|
---|
[24651] | 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 |
|
---|
[25174] | 546 | $failed
|
---|
[24651] | 547 |
|
---|
| 548 | EOF
|
---|
| 549 |
|
---|
[24410] | 550 | # Remove X.Org drivers
|
---|
[56776] | 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
|
---|
[24410] | 562 |
|
---|
| 563 | # Remove the link to vboxvideo_dri.so
|
---|
[56776] | 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
|
---|
[24410] | 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
|
---|
[53383] | 579 | rm /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[24410] | 580 |
|
---|
| 581 | # Remove other files
|
---|
| 582 | rm /usr/share/xserver-xorg/pci/vboxvideo.ids 2>/dev/null
|
---|
[70937] | 583 | return 0
|
---|
[24410] | 584 | }
|
---|
| 585 |
|
---|
| 586 | dmnstatus()
|
---|
| 587 | {
|
---|
[24950] | 588 | /bin/true
|
---|
[24410] | 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
|
---|