[24410] | 1 | #! /bin/sh
|
---|
[69327] | 2 | # $Id: vboxadd-x11.sh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
| 3 | ## @file
|
---|
[24410] | 4 | # Linux Additions X11 setup init script ($Revision: 98103 $)
|
---|
| 5 | #
|
---|
| 6 |
|
---|
| 7 | #
|
---|
[98103] | 8 | # Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[24410] | 9 | #
|
---|
[96407] | 10 | # This file is part of VirtualBox base platform packages, as
|
---|
| 11 | # available from https://www.virtualbox.org.
|
---|
[24410] | 12 | #
|
---|
[96407] | 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 | #
|
---|
[24410] | 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
|
---|
[24651] | 43 | CONFIG_DIR="/var/lib/VBoxGuestAdditions"
|
---|
[63889] | 44 | CONFIG="${CONFIG_DIR}/config"
|
---|
[59199] | 45 | MODPROBE=/sbin/modprobe
|
---|
[24410] | 46 |
|
---|
[59199] | 47 | if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules *0'; then
|
---|
| 48 | MODPROBE="$MODPROBE --allow-unsupported-modules"
|
---|
| 49 | fi
|
---|
| 50 |
|
---|
[24410] | 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'`
|
---|
[45135] | 55 | x_version_short=`echo "${x_version}" | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/'`
|
---|
[24410] | 56 | # Version of Redhat or Fedora installed. Needed for setting up selinux policy.
|
---|
| 57 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
---|
[67658] | 58 | # Version of OL installed. Needed for blacklisting vboxvideo.
|
---|
| 59 | oracle_release=`cat /etc/oracle-release 2> /dev/null`
|
---|
[24410] | 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 |
|
---|
[57945] | 69 | # Preamble for Gentoo
|
---|
| 70 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
| 71 | shift
|
---|
[24410] | 72 | fi
|
---|
| 73 |
|
---|
| 74 | dev=/dev/vboxguest
|
---|
| 75 | userdev=/dev/vboxuser
|
---|
| 76 | owner=vboxadd
|
---|
| 77 | group=1
|
---|
| 78 |
|
---|
| 79 | fail()
|
---|
| 80 | {
|
---|
[63870] | 81 | echo "${1}" >&2
|
---|
[24410] | 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() {
|
---|
[24651] | 91 | self="install_x11_startup_app"
|
---|
[24410] | 92 | app_src=$1
|
---|
| 93 | desktop_src=$2
|
---|
| 94 | service_name=$3
|
---|
| 95 | alt_command=$4
|
---|
[63870] | 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"
|
---|
[24410] | 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
|
---|
[63870] | 137 | cat >&2 << EOF
|
---|
[24651] | 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.
|
---|
[24410] | 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 |
|
---|
[75428] | 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
|
---|
[77049] | 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
|
---|
[75428] | 181 | fi
|
---|
| 182 | echo "/var/lib/VBoxGuestAdditions/lib" > /etc/ld.so.conf.d/00vboxvideo.conf
|
---|
| 183 | fi
|
---|
| 184 | ldconfig
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[24410] | 187 | setup()
|
---|
| 188 | {
|
---|
[63889] | 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"
|
---|
[63890] | 196 | lib_dir="${INSTALL_DIR}/other"
|
---|
| 197 | test -x "${lib_dir}" ||
|
---|
[63870] | 198 | fail "Invalid Guest Additions configuration found."
|
---|
[24651] | 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"
|
---|
[46563] | 203 | # All but the oldest supported X servers can automatically set up the
|
---|
| 204 | # keyboard driver.
|
---|
| 205 | autokeyboard="--autoKeyboard"
|
---|
[38784] | 206 | # On more recent servers our kernel mouse driver will be used
|
---|
| 207 | # automatically
|
---|
[26386] | 208 | automouse="--autoMouse"
|
---|
[25174] | 209 | # We need to tell our xorg.conf hacking script whether /dev/psaux exists
|
---|
| 210 | nopsaux="--nopsaux"
|
---|
[39809] | 211 | case "`uname -r`" in 2.4.*)
|
---|
| 212 | test -c /dev/psaux && nopsaux="";;
|
---|
| 213 | esac
|
---|
[50312] | 214 | # Should we use the VMSVGA driver instead of VBoxVideo?
|
---|
[50499] | 215 | if grep 80eebeef /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 216 | vmsvga=""
|
---|
[50499] | 217 | elif grep 15ad0405 /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 218 | vmsvga="--vmsvga"
|
---|
[50499] | 219 | else
|
---|
| 220 | dox11config=""
|
---|
[50312] | 221 | fi
|
---|
[24410] | 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=
|
---|
[38823] | 226 | # The driver extension
|
---|
| 227 | driver_ext=".so"
|
---|
[46574] | 228 | # The configuration file we generate if no original was found but we need
|
---|
| 229 | # one.
|
---|
| 230 | main_cfg="/etc/X11/xorg.conf"
|
---|
[24410] | 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 |
|
---|
[67858] | 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
|
---|
[68684] | 253 | test -d /etc/modprobe.d &&
|
---|
| 254 | echo "blacklist vboxvideo" > /etc/modprobe.d/blacklist-vboxvideo.conf
|
---|
[67858] | 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 |
|
---|
[24410] | 264 | test -z "$x_version" -o -z "$modules_dir" &&
|
---|
[50107] | 265 | {
|
---|
[63870] | 266 | echo "Could not find the X.Org or XFree86 Window System, skipping." >&2
|
---|
[50107] | 267 | exit 0
|
---|
| 268 | }
|
---|
[24410] | 269 |
|
---|
[35209] | 270 | # openSUSE 10.3 shipped X.Org 7.2 with X.Org Server 1.3, but didn't
|
---|
| 271 | # advertise the fact.
|
---|
[35210] | 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
|
---|
[24410] | 277 | case $x_version in
|
---|
[36388] | 278 | 1.*.99.* )
|
---|
[63870] | 279 | echo "Warning: unsupported pre-release version of X.Org Server installed. Not installing the X.Org drivers." >&2
|
---|
[24651] | 280 | dox11config=""
|
---|
[24410] | 281 | ;;
|
---|
[38826] | 282 | 1.11.* )
|
---|
| 283 | xserver_version="X.Org Server 1.11"
|
---|
| 284 | vboxvideo_src=vboxvideo_drv_111.so
|
---|
[50312] | 285 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[38826] | 286 | ;;
|
---|
[36301] | 287 | 1.10.* )
|
---|
[38823] | 288 | xserver_version="X.Org Server 1.10"
|
---|
[35841] | 289 | vboxvideo_src=vboxvideo_drv_110.so
|
---|
[50312] | 290 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[35841] | 291 | ;;
|
---|
[36388] | 292 | 1.9.* )
|
---|
[38823] | 293 | xserver_version="X.Org Server 1.9"
|
---|
[32166] | 294 | vboxvideo_src=vboxvideo_drv_19.so
|
---|
[44936] | 295 | # Fedora 14 to 16 patched out vboxvideo detection
|
---|
[50312] | 296 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[32166] | 297 | ;;
|
---|
[36388] | 298 | 1.8.* )
|
---|
[38823] | 299 | xserver_version="X.Org Server 1.8"
|
---|
[28064] | 300 | vboxvideo_src=vboxvideo_drv_18.so
|
---|
[32166] | 301 | # Fedora 13 shipped without vboxvideo detection
|
---|
[50312] | 302 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[28064] | 303 | ;;
|
---|
[36388] | 304 | 1.7.* )
|
---|
[38823] | 305 | xserver_version="X.Org Server 1.7"
|
---|
[24410] | 306 | vboxvideo_src=vboxvideo_drv_17.so
|
---|
[24651] | 307 | setupxorgconf=""
|
---|
[24410] | 308 | ;;
|
---|
[36388] | 309 | 1.6.* )
|
---|
[38823] | 310 | xserver_version="X.Org Server 1.6"
|
---|
[24410] | 311 | vboxvideo_src=vboxvideo_drv_16.so
|
---|
| 312 | vboxmouse_src=vboxmouse_drv_16.so
|
---|
[36666] | 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
|
---|
[24410] | 320 | ;;
|
---|
[36388] | 321 | 1.5.* )
|
---|
[38823] | 322 | xserver_version="X.Org Server 1.5"
|
---|
[24410] | 323 | vboxvideo_src=vboxvideo_drv_15.so
|
---|
| 324 | vboxmouse_src=vboxmouse_drv_15.so
|
---|
[49196] | 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=""
|
---|
[24410] | 331 | ;;
|
---|
| 332 | 1.4.* )
|
---|
[38823] | 333 | xserver_version="X.Org Server 1.4"
|
---|
[24410] | 334 | vboxvideo_src=vboxvideo_drv_14.so
|
---|
| 335 | vboxmouse_src=vboxmouse_drv_14.so
|
---|
[26386] | 336 | automouse=""
|
---|
[24410] | 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'.
|
---|
[38823] | 341 | xserver_version="X.Org Server 1.3"
|
---|
[24410] | 342 | vboxvideo_src=vboxvideo_drv_13.so
|
---|
[25084] | 343 | vboxmouse_src=vboxmouse_drv_13.so
|
---|
[26386] | 344 | automouse=""
|
---|
[24410] | 345 | ;;
|
---|
| 346 | 7.1.* | 7.2.* )
|
---|
[38823] | 347 | xserver_version="X.Org 7.1"
|
---|
[24410] | 348 | vboxvideo_src=vboxvideo_drv_71.so
|
---|
| 349 | vboxmouse_src=vboxmouse_drv_71.so
|
---|
[26386] | 350 | automouse=""
|
---|
[24410] | 351 | ;;
|
---|
| 352 | 6.9.* | 7.0.* )
|
---|
[38823] | 353 | xserver_version="X.Org 6.9/7.0"
|
---|
[24410] | 354 | vboxvideo_src=vboxvideo_drv_70.so
|
---|
| 355 | vboxmouse_src=vboxmouse_drv_70.so
|
---|
[26386] | 356 | automouse=""
|
---|
[24410] | 357 | ;;
|
---|
| 358 | 6.7* | 6.8.* | 4.2.* | 4.3.* )
|
---|
[46574] | 359 | # As the module binaries are the same we use one text for these
|
---|
| 360 | # four server versions.
|
---|
[38823] | 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
|
---|
[26386] | 365 | automouse=""
|
---|
[46574] | 366 | autokeyboard=""
|
---|
| 367 | case $x_version in
|
---|
| 368 | 6.8.* )
|
---|
[70937] | 369 | autokeyboard="--autoKeyboard"
|
---|
[46574] | 370 | ;;
|
---|
| 371 | 4.2.* | 4.3.* )
|
---|
| 372 | main_cfg="/etc/X11/XF86Config"
|
---|
| 373 | ;;
|
---|
| 374 | esac
|
---|
[24410] | 375 | ;;
|
---|
[60105] | 376 | 1.12.* | 1.13.* | 1.14.* | 1.15.* | 1.16.* | 1.17.* | 1.18.* )
|
---|
[45135] | 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 | {
|
---|
[63870] | 382 | echo "Warning: unknown version of the X Window System installed. Not installing X Window System drivers." >&2
|
---|
[45135] | 383 | dox11config=""
|
---|
| 384 | vboxvideo_src=""
|
---|
| 385 | }
|
---|
[24410] | 386 | ;;
|
---|
[59199] | 387 | * )
|
---|
| 388 | # For anything else, assume kernel drivers.
|
---|
| 389 | dox11config=""
|
---|
| 390 | ;;
|
---|
[24410] | 391 | esac
|
---|
[45135] | 392 | test -n "${dox11config}" &&
|
---|
[63870] | 393 | echo "Installing $xserver_version modules" >&2
|
---|
[60317] | 394 | case "$vboxvideo_src" in
|
---|
| 395 | ?*)
|
---|
[63890] | 396 | ln -s "${lib_dir}/$vboxvideo_src" "$modules_dir/drivers/vboxvideo_drv$driver_ext.new" &&
|
---|
[60317] | 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
|
---|
[38823] | 400 | esac
|
---|
[60317] | 401 | case "$vboxmouse_src" in
|
---|
| 402 | ?*)
|
---|
[63890] | 403 | ln -s "${lib_dir}/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv$driver_ext.new" &&
|
---|
[60350] | 404 | mv "$modules_dir/input/vboxmouse_drv$driver_ext.new" "$modules_dir/input/vboxmouse_drv$driver_ext";;
|
---|
[60317] | 405 | *)
|
---|
| 406 | rm "$modules_dir/input/vboxmouse_drv$driver_ext" 2>/dev/null
|
---|
[38823] | 407 | esac
|
---|
[24651] | 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.
|
---|
[26386] | 414 | test "$system" = "debian" -a -d /usr/share/xserver-xorg/pci &&
|
---|
[24651] | 415 | {
|
---|
| 416 | rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
|
---|
[63890] | 417 | ln -s "${lib_dir}/vboxvideo.ids" /usr/share/xserver-xorg/pci 2>/dev/null
|
---|
[26386] | 418 | test -n "$automouse" && setupxorgconf=""
|
---|
[24651] | 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
|
---|
[63890] | 430 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga "$i"
|
---|
[24651] | 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.
|
---|
[46574] | 440 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
[26531] | 441 | if test -z "$configured"; then
|
---|
[24651] | 442 | touch "$main_cfg"
|
---|
[63890] | 443 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga --noBak "$main_cfg"
|
---|
[46574] | 444 | touch "${nobak_cfg}"
|
---|
[24651] | 445 | fi
|
---|
| 446 | fi
|
---|
| 447 | test -n "$generated" &&
|
---|
[63870] | 448 | cat >&2 << EOF
|
---|
[24651] | 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
|
---|
[63870] | 455 | tty >/dev/null && cat << EOF
|
---|
[64525] | 456 | You may need to restart the Window System (or just restart the guest system)
|
---|
[49196] | 457 | to enable the Guest Additions.
|
---|
[24739] | 458 |
|
---|
| 459 | EOF
|
---|
[24651] | 460 | fi
|
---|
| 461 |
|
---|
[24410] | 462 | case "$redhat_release" in
|
---|
[37104] | 463 | # Install selinux policy for Fedora 7 and 8 to allow the X server to
|
---|
| 464 | # open device files
|
---|
[24410] | 465 | Fedora\ release\ 7* | Fedora\ release\ 8* )
|
---|
[63890] | 466 | semodule -i "${lib_dir}/vbox_x11.pp" > /dev/null 2>&1
|
---|
[24410] | 467 | ;;
|
---|
[37104] | 468 | # Similar for the accelerated graphics check on Fedora 15
|
---|
| 469 | Fedora\ release\ 15* )
|
---|
[63890] | 470 | semodule -i "${lib_dir}/vbox_accel.pp" > /dev/null 2>&1
|
---|
[37104] | 471 | ;;
|
---|
[24410] | 472 | esac
|
---|
| 473 |
|
---|
[25081] | 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* )
|
---|
[77049] | 478 | chcon -u system_u -t lib_t "${lib_dir}"/*.so 2>/dev/null
|
---|
[25081] | 479 | ;;
|
---|
| 480 | esac
|
---|
| 481 |
|
---|
[24410] | 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.
|
---|
[77049] | 485 | # chcon is needed on old Fedora/Redhat systems. No one remembers which.
|
---|
[24410] | 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
|
---|
[63890] | 490 | install_x11_startup_app "${lib_dir}/98vboxadd-xclient" "${lib_dir}/vboxclient.desktop" VBoxClient VBoxClient-all ||
|
---|
[68705] | 491 | fail "Failed to set up VBoxClient to start automatically."
|
---|
[63890] | 492 | ln -s "${lib_dir}/98vboxadd-xclient" /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[75428] | 493 | case "${x_version}" in 4.* | 6.* | 7.* | 1.?.* | 1.1* )
|
---|
| 494 | setup_opengl
|
---|
[75439] | 495 | esac
|
---|
[75837] | 496 | # Try enabling VMSVGA drm device resizing.
|
---|
[83249] | 497 | #VBoxClient --vmsvga
|
---|
[24410] | 498 | }
|
---|
| 499 |
|
---|
| 500 | cleanup()
|
---|
| 501 | {
|
---|
| 502 | # Restore xorg.conf files as far as possible
|
---|
[46574] | 503 | # List of generated files which have been changed since we generated them
|
---|
[24651] | 504 | newer=""
|
---|
[46574] | 505 | # Are we dealing with a legacy information which didn't support
|
---|
[24651] | 506 | # uninstallation?
|
---|
| 507 | legacy=""
|
---|
[46574] | 508 | # Do any of the restored configuration files still reference our drivers?
|
---|
[24651] | 509 | failed=""
|
---|
[46574] | 510 | # Have we encountered a "nobak" configuration file which means that there
|
---|
| 511 | # is no original file to restore?
|
---|
| 512 | nobak=""
|
---|
[24651] | 513 | test -r "$CONFIG_DIR/$CONFIG" || legacy="true"
|
---|
[46574] | 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}"
|
---|
[24651] | 520 | else
|
---|
[46574] | 521 | newer="${newer}`printf " ${main_cfg} (no original)\n"`"
|
---|
[24410] | 522 | fi
|
---|
[46574] | 523 | nobak="true"
|
---|
| 524 | fi
|
---|
| 525 | done
|
---|
[56776] | 526 | if test -z "${nobak}"; then
|
---|
[24651] | 527 | for i in $x11conf_files; do
|
---|
| 528 | if test -r "$i.vbox"; then
|
---|
[25174] | 529 | if test ! "$i" -nt "$i.vbox" -o -n "$legacy"; then
|
---|
[24651] | 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
|
---|
[24410] | 536 | fi
|
---|
[24651] | 537 | done
|
---|
| 538 | fi
|
---|
[63870] | 539 | test -n "$newer" && cat >&2 << EOF
|
---|
[24651] | 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 |
|
---|
[24410] | 548 | EOF
|
---|
[63870] | 549 | test -n "$failed" && cat >&2 << EOF
|
---|
[24410] | 550 |
|
---|
[24651] | 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 |
|
---|
[25174] | 556 | $failed
|
---|
[24651] | 557 |
|
---|
| 558 | EOF
|
---|
| 559 |
|
---|
[24410] | 560 | # Remove X.Org drivers
|
---|
[56776] | 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
|
---|
[24410] | 572 |
|
---|
| 573 | # Remove the link to vboxvideo_dri.so
|
---|
[56776] | 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
|
---|
[24410] | 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
|
---|
[53383] | 589 | rm /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[24410] | 590 |
|
---|
| 591 | # Remove other files
|
---|
| 592 | rm /usr/share/xserver-xorg/pci/vboxvideo.ids 2>/dev/null
|
---|
[70937] | 593 | return 0
|
---|
[24410] | 594 | }
|
---|
| 595 |
|
---|
| 596 | dmnstatus()
|
---|
| 597 | {
|
---|
[24950] | 598 | /bin/true
|
---|
[24410] | 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
|
---|