[24410] | 1 | #! /bin/sh
|
---|
[69327] | 2 | # $Id: vboxadd-x11.sh 69500 2017-10-28 15:14:05Z vboxsync $
|
---|
| 3 | ## @file
|
---|
[24410] | 4 | # Linux Additions X11 setup init script ($Revision: 69500 $)
|
---|
| 5 | #
|
---|
| 6 |
|
---|
| 7 | #
|
---|
[69500] | 8 | # Copyright (C) 2006-2017 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 |
|
---|
| 153 | setup()
|
---|
| 154 | {
|
---|
[63889] | 155 | if test -r "${CONFIG}"; then
|
---|
| 156 | . "${CONFIG}"
|
---|
| 157 | else
|
---|
| 158 | fail "Configuration file ${CONFIG} not found"
|
---|
| 159 | fi
|
---|
| 160 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
| 161 | fail "Configuration file ${CONFIG} not complete"
|
---|
[63890] | 162 | lib_dir="${INSTALL_DIR}/other"
|
---|
| 163 | test -x "${lib_dir}" ||
|
---|
[63870] | 164 | fail "Invalid Guest Additions configuration found."
|
---|
[24651] | 165 | # By default we want to configure X
|
---|
| 166 | dox11config="true"
|
---|
| 167 | # By default, we want to run our xorg.conf setup script
|
---|
| 168 | setupxorgconf="true"
|
---|
[46563] | 169 | # All but the oldest supported X servers can automatically set up the
|
---|
| 170 | # keyboard driver.
|
---|
| 171 | autokeyboard="--autoKeyboard"
|
---|
[38784] | 172 | # On more recent servers our kernel mouse driver will be used
|
---|
| 173 | # automatically
|
---|
[26386] | 174 | automouse="--autoMouse"
|
---|
[25174] | 175 | # We need to tell our xorg.conf hacking script whether /dev/psaux exists
|
---|
| 176 | nopsaux="--nopsaux"
|
---|
[39809] | 177 | case "`uname -r`" in 2.4.*)
|
---|
| 178 | test -c /dev/psaux && nopsaux="";;
|
---|
| 179 | esac
|
---|
[50312] | 180 | # Should we use the VMSVGA driver instead of VBoxVideo?
|
---|
[50499] | 181 | if grep 80eebeef /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 182 | vmsvga=""
|
---|
[50499] | 183 | elif grep 15ad0405 /proc/bus/pci/devices > /dev/null; then
|
---|
[50312] | 184 | vmsvga="--vmsvga"
|
---|
[50499] | 185 | else
|
---|
| 186 | dox11config=""
|
---|
[50312] | 187 | fi
|
---|
[24410] | 188 | # The video driver to install for X.Org 6.9+
|
---|
| 189 | vboxvideo_src=
|
---|
| 190 | # The mouse driver to install for X.Org 6.9+
|
---|
| 191 | vboxmouse_src=
|
---|
[38823] | 192 | # The driver extension
|
---|
| 193 | driver_ext=".so"
|
---|
[46574] | 194 | # The configuration file we generate if no original was found but we need
|
---|
| 195 | # one.
|
---|
| 196 | main_cfg="/etc/X11/xorg.conf"
|
---|
[24410] | 197 |
|
---|
| 198 | modules_dir=`X -showDefaultModulePath 2>&1` || modules_dir=
|
---|
| 199 | if [ -z "$modules_dir" ]; then
|
---|
| 200 | 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
|
---|
| 201 | if [ -d $dir ]; then
|
---|
| 202 | modules_dir=$dir
|
---|
| 203 | break
|
---|
| 204 | fi
|
---|
| 205 | done
|
---|
| 206 | fi
|
---|
| 207 |
|
---|
[67858] | 208 | case "${x_version}" in
|
---|
| 209 | 4.* | 6.* | 7.* | 1.?.* | 1.1[0-6].* )
|
---|
| 210 | blacklist_vboxvideo="yes"
|
---|
| 211 | ;;
|
---|
| 212 | esac
|
---|
| 213 | case "$oracle_release" in
|
---|
| 214 | Oracle*release\ 6.* )
|
---|
| 215 | # relevant for OL6/UEK4 but cannot hurt for other kernels
|
---|
| 216 | blacklist_vboxvideo="yes"
|
---|
| 217 | esac
|
---|
| 218 | if test -n "${blacklist_vboxvideo}"; then
|
---|
[68684] | 219 | test -d /etc/modprobe.d &&
|
---|
| 220 | echo "blacklist vboxvideo" > /etc/modprobe.d/blacklist-vboxvideo.conf
|
---|
[67858] | 221 | else
|
---|
| 222 | test -f /etc/modprobe.d/blacklist-vboxvideo.conf &&
|
---|
| 223 | rm -f /etc/modprobe.d/blacklist-vboxvideo.conf
|
---|
| 224 | # We do not want to load the driver if X.Org Server is already
|
---|
| 225 | # running, as without a driver the server will touch the hardware
|
---|
| 226 | # directly, causing problems.
|
---|
| 227 | ps -Af | grep -q '[X]org' || ${MODPROBE} -q vboxvideo
|
---|
| 228 | fi
|
---|
| 229 |
|
---|
[24410] | 230 | test -z "$x_version" -o -z "$modules_dir" &&
|
---|
[50107] | 231 | {
|
---|
[63870] | 232 | echo "Could not find the X.Org or XFree86 Window System, skipping." >&2
|
---|
[50107] | 233 | exit 0
|
---|
| 234 | }
|
---|
[24410] | 235 |
|
---|
[35209] | 236 | # openSUSE 10.3 shipped X.Org 7.2 with X.Org Server 1.3, but didn't
|
---|
| 237 | # advertise the fact.
|
---|
[35210] | 238 | if grep -q '10\.3' /etc/SuSE-release 2>/dev/null; then
|
---|
| 239 | case $x_version in 7.2.*)
|
---|
| 240 | x_version=1.3.0;;
|
---|
| 241 | esac
|
---|
| 242 | fi
|
---|
[24410] | 243 | case $x_version in
|
---|
[36388] | 244 | 1.*.99.* )
|
---|
[63870] | 245 | echo "Warning: unsupported pre-release version of X.Org Server installed. Not installing the X.Org drivers." >&2
|
---|
[24651] | 246 | dox11config=""
|
---|
[24410] | 247 | ;;
|
---|
[38826] | 248 | 1.11.* )
|
---|
| 249 | xserver_version="X.Org Server 1.11"
|
---|
| 250 | vboxvideo_src=vboxvideo_drv_111.so
|
---|
[50312] | 251 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[38826] | 252 | ;;
|
---|
[36301] | 253 | 1.10.* )
|
---|
[38823] | 254 | xserver_version="X.Org Server 1.10"
|
---|
[35841] | 255 | vboxvideo_src=vboxvideo_drv_110.so
|
---|
[50312] | 256 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[35841] | 257 | ;;
|
---|
[36388] | 258 | 1.9.* )
|
---|
[38823] | 259 | xserver_version="X.Org Server 1.9"
|
---|
[32166] | 260 | vboxvideo_src=vboxvideo_drv_19.so
|
---|
[44936] | 261 | # Fedora 14 to 16 patched out vboxvideo detection
|
---|
[50312] | 262 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[32166] | 263 | ;;
|
---|
[36388] | 264 | 1.8.* )
|
---|
[38823] | 265 | xserver_version="X.Org Server 1.8"
|
---|
[28064] | 266 | vboxvideo_src=vboxvideo_drv_18.so
|
---|
[32166] | 267 | # Fedora 13 shipped without vboxvideo detection
|
---|
[50312] | 268 | test "$system" = "redhat" && test -z "${vmsvga}" || setupxorgconf=""
|
---|
[28064] | 269 | ;;
|
---|
[36388] | 270 | 1.7.* )
|
---|
[38823] | 271 | xserver_version="X.Org Server 1.7"
|
---|
[24410] | 272 | vboxvideo_src=vboxvideo_drv_17.so
|
---|
[24651] | 273 | setupxorgconf=""
|
---|
[24410] | 274 | ;;
|
---|
[36388] | 275 | 1.6.* )
|
---|
[38823] | 276 | xserver_version="X.Org Server 1.6"
|
---|
[24410] | 277 | vboxvideo_src=vboxvideo_drv_16.so
|
---|
| 278 | vboxmouse_src=vboxmouse_drv_16.so
|
---|
[36666] | 279 | # SUSE SLE* with X.Org 1.6 does not do input autodetection;
|
---|
| 280 | # openSUSE does.
|
---|
| 281 | if grep -q -E '^SLE[^ ]' /etc/SuSE-brand 2>/dev/null; then
|
---|
| 282 | automouse=""
|
---|
| 283 | else
|
---|
| 284 | test "$system" = "suse" && setupxorgconf=""
|
---|
| 285 | fi
|
---|
[24410] | 286 | ;;
|
---|
[36388] | 287 | 1.5.* )
|
---|
[38823] | 288 | xserver_version="X.Org Server 1.5"
|
---|
[24410] | 289 | vboxvideo_src=vboxvideo_drv_15.so
|
---|
| 290 | vboxmouse_src=vboxmouse_drv_15.so
|
---|
[49196] | 291 | # Historical note: SUSE with X.Org Server 1.5 disabled automatic
|
---|
| 292 | # mouse configuration and was handled specially. However since our
|
---|
| 293 | # kernel driver seems to have problems with X.Org Server 1.5 anyway
|
---|
| 294 | # we just create an X.Org configuration file and use the user space
|
---|
| 295 | # one generally, no longer just for SUSE.
|
---|
| 296 | automouse=""
|
---|
[24410] | 297 | ;;
|
---|
| 298 | 1.4.* )
|
---|
[38823] | 299 | xserver_version="X.Org Server 1.4"
|
---|
[24410] | 300 | vboxvideo_src=vboxvideo_drv_14.so
|
---|
| 301 | vboxmouse_src=vboxmouse_drv_14.so
|
---|
[26386] | 302 | automouse=""
|
---|
[24410] | 303 | ;;
|
---|
| 304 | 1.3.* )
|
---|
| 305 | # This was the first release which gave the server version number
|
---|
| 306 | # rather than the X11 release version when you did 'X -version'.
|
---|
[38823] | 307 | xserver_version="X.Org Server 1.3"
|
---|
[24410] | 308 | vboxvideo_src=vboxvideo_drv_13.so
|
---|
[25084] | 309 | vboxmouse_src=vboxmouse_drv_13.so
|
---|
[26386] | 310 | automouse=""
|
---|
[24410] | 311 | ;;
|
---|
| 312 | 7.1.* | 7.2.* )
|
---|
[38823] | 313 | xserver_version="X.Org 7.1"
|
---|
[24410] | 314 | vboxvideo_src=vboxvideo_drv_71.so
|
---|
| 315 | vboxmouse_src=vboxmouse_drv_71.so
|
---|
[26386] | 316 | automouse=""
|
---|
[24410] | 317 | ;;
|
---|
| 318 | 6.9.* | 7.0.* )
|
---|
[38823] | 319 | xserver_version="X.Org 6.9/7.0"
|
---|
[24410] | 320 | vboxvideo_src=vboxvideo_drv_70.so
|
---|
| 321 | vboxmouse_src=vboxmouse_drv_70.so
|
---|
[26386] | 322 | automouse=""
|
---|
[24410] | 323 | ;;
|
---|
| 324 | 6.7* | 6.8.* | 4.2.* | 4.3.* )
|
---|
[46574] | 325 | # As the module binaries are the same we use one text for these
|
---|
| 326 | # four server versions.
|
---|
[38823] | 327 | xserver_version="XFree86 4.2/4.3 and X.Org 6.7/6.8"
|
---|
| 328 | driver_ext=.o
|
---|
| 329 | vboxvideo_src=vboxvideo_drv.o
|
---|
| 330 | vboxmouse_src=vboxmouse_drv.o
|
---|
[26386] | 331 | automouse=""
|
---|
[46574] | 332 | autokeyboard=""
|
---|
| 333 | case $x_version in
|
---|
| 334 | 6.8.* )
|
---|
| 335 | autokeyboard="true"
|
---|
| 336 | ;;
|
---|
| 337 | 4.2.* | 4.3.* )
|
---|
| 338 | main_cfg="/etc/X11/XF86Config"
|
---|
| 339 | ;;
|
---|
| 340 | esac
|
---|
[24410] | 341 | ;;
|
---|
[60105] | 342 | 1.12.* | 1.13.* | 1.14.* | 1.15.* | 1.16.* | 1.17.* | 1.18.* )
|
---|
[45135] | 343 | xserver_version="X.Org Server ${x_version_short}"
|
---|
| 344 | vboxvideo_src=vboxvideo_drv_`echo ${x_version_short} | sed 's/\.//'`.so
|
---|
| 345 | setupxorgconf=""
|
---|
| 346 | test -f "${lib_dir}/${vboxvideo_src}" ||
|
---|
| 347 | {
|
---|
[63870] | 348 | echo "Warning: unknown version of the X Window System installed. Not installing X Window System drivers." >&2
|
---|
[45135] | 349 | dox11config=""
|
---|
| 350 | vboxvideo_src=""
|
---|
| 351 | }
|
---|
[24410] | 352 | ;;
|
---|
[59199] | 353 | * )
|
---|
| 354 | # For anything else, assume kernel drivers.
|
---|
| 355 | dox11config=""
|
---|
| 356 | ;;
|
---|
[24410] | 357 | esac
|
---|
[45135] | 358 | test -n "${dox11config}" &&
|
---|
[63870] | 359 | echo "Installing $xserver_version modules" >&2
|
---|
[60317] | 360 | case "$vboxvideo_src" in
|
---|
| 361 | ?*)
|
---|
[63890] | 362 | ln -s "${lib_dir}/$vboxvideo_src" "$modules_dir/drivers/vboxvideo_drv$driver_ext.new" &&
|
---|
[60317] | 363 | mv "$modules_dir/drivers/vboxvideo_drv$driver_ext.new" "$modules_dir/drivers/vboxvideo_drv$driver_ext";;
|
---|
| 364 | *)
|
---|
| 365 | rm "$modules_dir/drivers/vboxvideo_drv$driver_ext" 2>/dev/null
|
---|
[38823] | 366 | esac
|
---|
[60317] | 367 | case "$vboxmouse_src" in
|
---|
| 368 | ?*)
|
---|
[63890] | 369 | ln -s "${lib_dir}/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv$driver_ext.new" &&
|
---|
[60350] | 370 | mv "$modules_dir/input/vboxmouse_drv$driver_ext.new" "$modules_dir/input/vboxmouse_drv$driver_ext";;
|
---|
[60317] | 371 | *)
|
---|
| 372 | rm "$modules_dir/input/vboxmouse_drv$driver_ext" 2>/dev/null
|
---|
[38823] | 373 | esac
|
---|
[24651] | 374 |
|
---|
| 375 | if test -n "$dox11config"; then
|
---|
| 376 | # Certain Ubuntu/Debian versions use a special PCI-id file to identify
|
---|
| 377 | # video drivers. Some versions have the directory and don't use it.
|
---|
| 378 | # Those versions can autoload vboxvideo though, so we don't need to
|
---|
| 379 | # hack the configuration file for them.
|
---|
[26386] | 380 | test "$system" = "debian" -a -d /usr/share/xserver-xorg/pci &&
|
---|
[24651] | 381 | {
|
---|
| 382 | rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
|
---|
[63890] | 383 | ln -s "${lib_dir}/vboxvideo.ids" /usr/share/xserver-xorg/pci 2>/dev/null
|
---|
[26386] | 384 | test -n "$automouse" && setupxorgconf=""
|
---|
[24651] | 385 | }
|
---|
| 386 |
|
---|
| 387 | # Do the XF86Config/xorg.conf hack for those versions that require it
|
---|
| 388 | configured=""
|
---|
| 389 | generated=""
|
---|
| 390 | if test -n "$setupxorgconf"; then
|
---|
| 391 | for i in $x11conf_files; do
|
---|
| 392 | if test -r "$i"; then
|
---|
| 393 | if grep -q "VirtualBox generated" "$i"; then
|
---|
| 394 | generated="$generated `printf "$i\n"`"
|
---|
| 395 | else
|
---|
[63890] | 396 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga "$i"
|
---|
[24651] | 397 | fi
|
---|
| 398 | configured="true"
|
---|
| 399 | fi
|
---|
| 400 | # Timestamp, so that we can see if the config file is changed
|
---|
| 401 | # by someone else later
|
---|
| 402 | test -r "$i.vbox" && touch "$i.vbox"
|
---|
| 403 | done
|
---|
| 404 | # X.Org Server 1.5 and 1.6 can detect hardware they know, but they
|
---|
| 405 | # need a configuration file for VBoxVideo.
|
---|
[46574] | 406 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
[26531] | 407 | if test -z "$configured"; then
|
---|
[24651] | 408 | touch "$main_cfg"
|
---|
[63890] | 409 | "${lib_dir}/x11config.sh" $autokeyboard $automouse $nopsaux $vmsvga --noBak "$main_cfg"
|
---|
[46574] | 410 | touch "${nobak_cfg}"
|
---|
[24651] | 411 | fi
|
---|
| 412 | fi
|
---|
| 413 | test -n "$generated" &&
|
---|
[63870] | 414 | cat >&2 << EOF
|
---|
[24651] | 415 | The following X.Org/XFree86 configuration files were originally generated by
|
---|
| 416 | the VirtualBox Guest Additions and were not modified:
|
---|
| 417 |
|
---|
| 418 | $generated
|
---|
| 419 |
|
---|
| 420 | EOF
|
---|
[63870] | 421 | tty >/dev/null && cat << EOF
|
---|
[64525] | 422 | You may need to restart the Window System (or just restart the guest system)
|
---|
[49196] | 423 | to enable the Guest Additions.
|
---|
[24739] | 424 |
|
---|
| 425 | EOF
|
---|
[24651] | 426 | fi
|
---|
| 427 |
|
---|
[24410] | 428 | case "$redhat_release" in
|
---|
[37104] | 429 | # Install selinux policy for Fedora 7 and 8 to allow the X server to
|
---|
| 430 | # open device files
|
---|
[24410] | 431 | Fedora\ release\ 7* | Fedora\ release\ 8* )
|
---|
[63890] | 432 | semodule -i "${lib_dir}/vbox_x11.pp" > /dev/null 2>&1
|
---|
[24410] | 433 | ;;
|
---|
[37104] | 434 | # Similar for the accelerated graphics check on Fedora 15
|
---|
| 435 | Fedora\ release\ 15* )
|
---|
[63890] | 436 | semodule -i "${lib_dir}/vbox_accel.pp" > /dev/null 2>&1
|
---|
[37104] | 437 | ;;
|
---|
[24410] | 438 | esac
|
---|
| 439 |
|
---|
[25081] | 440 | # Install selinux policy for Fedora 8 to allow the X server to
|
---|
| 441 | # open our drivers
|
---|
| 442 | case "$redhat_release" in
|
---|
| 443 | Fedora\ release\ 8* )
|
---|
[63890] | 444 | chcon -u system_u -t lib_t "${lib_dir}"/*.so
|
---|
[25081] | 445 | ;;
|
---|
| 446 | esac
|
---|
| 447 |
|
---|
[24410] | 448 | # Our logging code generates some glue code on 32-bit systems. At least F10
|
---|
| 449 | # needs a rule to allow this. Send all output to /dev/null in case this is
|
---|
| 450 | # completely irrelevant on the target system.
|
---|
| 451 | chcon -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
---|
| 452 | semanage fcontext -a -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
---|
| 453 |
|
---|
| 454 | # And set up VBoxClient to start when the X session does
|
---|
[63890] | 455 | install_x11_startup_app "${lib_dir}/98vboxadd-xclient" "${lib_dir}/vboxclient.desktop" VBoxClient VBoxClient-all ||
|
---|
[68705] | 456 | fail "Failed to set up VBoxClient to start automatically."
|
---|
[63890] | 457 | ln -s "${lib_dir}/98vboxadd-xclient" /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[24410] | 458 | }
|
---|
| 459 |
|
---|
| 460 | cleanup()
|
---|
| 461 | {
|
---|
| 462 | # Restore xorg.conf files as far as possible
|
---|
[46574] | 463 | # List of generated files which have been changed since we generated them
|
---|
[24651] | 464 | newer=""
|
---|
[46574] | 465 | # Are we dealing with a legacy information which didn't support
|
---|
[24651] | 466 | # uninstallation?
|
---|
| 467 | legacy=""
|
---|
[46574] | 468 | # Do any of the restored configuration files still reference our drivers?
|
---|
[24651] | 469 | failed=""
|
---|
[46574] | 470 | # Have we encountered a "nobak" configuration file which means that there
|
---|
| 471 | # is no original file to restore?
|
---|
| 472 | nobak=""
|
---|
[24651] | 473 | test -r "$CONFIG_DIR/$CONFIG" || legacy="true"
|
---|
[46574] | 474 | for main_cfg in "/etc/X11/xorg.conf" "/etc/X11/XF86Config"; do
|
---|
| 475 | nobak_cfg="`expr "${main_cfg}" : '\([^.]*\)'`.vbox.nobak"
|
---|
| 476 | if test -r "${nobak_cfg}"; then
|
---|
| 477 | test -r "${main_cfg}" &&
|
---|
| 478 | if test -n "${legacy}" -o ! "${nobak_cfg}" -ot "${main_cfg}"; then
|
---|
| 479 | rm -f "${nobak_cfg}" "${main_cfg}"
|
---|
[24651] | 480 | else
|
---|
[46574] | 481 | newer="${newer}`printf " ${main_cfg} (no original)\n"`"
|
---|
[24410] | 482 | fi
|
---|
[46574] | 483 | nobak="true"
|
---|
| 484 | fi
|
---|
| 485 | done
|
---|
[56776] | 486 | if test -z "${nobak}"; then
|
---|
[24651] | 487 | for i in $x11conf_files; do
|
---|
| 488 | if test -r "$i.vbox"; then
|
---|
[25174] | 489 | if test ! "$i" -nt "$i.vbox" -o -n "$legacy"; then
|
---|
[24651] | 490 | mv -f "$i.vbox" "$i"
|
---|
| 491 | grep -q -E 'vboxvideo|vboxmouse' "$i" &&
|
---|
| 492 | failed="$failed`printf " $i\n"`"
|
---|
| 493 | else
|
---|
| 494 | newer="$newer`printf " $i ($i.vbox)\n"`"
|
---|
| 495 | fi
|
---|
[24410] | 496 | fi
|
---|
[24651] | 497 | done
|
---|
| 498 | fi
|
---|
[63870] | 499 | test -n "$newer" && cat >&2 << EOF
|
---|
[24651] | 500 |
|
---|
| 501 | The following X.Org/XFree86 configuration files were not restored, as they may
|
---|
| 502 | have been changed since they were generated by the VirtualBox Guest Additions.
|
---|
| 503 | You may wish to restore these manually. The file name in brackets is the
|
---|
| 504 | original version.
|
---|
| 505 |
|
---|
| 506 | $newer
|
---|
| 507 |
|
---|
[24410] | 508 | EOF
|
---|
[63870] | 509 | test -n "$failed" && cat >&2 << EOF
|
---|
[24410] | 510 |
|
---|
[24651] | 511 | The following X.Org/XFree86 configuration files were restored, but still
|
---|
| 512 | contain references to the Guest Additions drivers. You may wish to check and
|
---|
| 513 | possibly correct the restored configuration files to be sure that the server
|
---|
| 514 | will continue to work after it is restarted.
|
---|
| 515 |
|
---|
[25174] | 516 | $failed
|
---|
[24651] | 517 |
|
---|
| 518 | EOF
|
---|
| 519 |
|
---|
[24410] | 520 | # Remove X.Org drivers
|
---|
[56776] | 521 | modules_dir=`X -showDefaultModulePath 2>&1` || modules_dir=
|
---|
| 522 | if [ -z "$modules_dir" ]; then
|
---|
| 523 | 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
|
---|
| 524 | if [ -d $dir ]; then
|
---|
| 525 | modules_dir=$dir
|
---|
| 526 | break
|
---|
| 527 | fi
|
---|
| 528 | done
|
---|
| 529 | fi
|
---|
| 530 | rm -f "$modules_dir/drivers/vboxvideo_drv"* 2>/dev/null
|
---|
| 531 | rm -f "$modules_dir/input/vboxmouse_drv"* 2>/dev/null
|
---|
[24410] | 532 |
|
---|
| 533 | # Remove the link to vboxvideo_dri.so
|
---|
[56776] | 534 | for dir in /usr/lib/dri /usr/lib32/dri /usr/lib64/dri \
|
---|
| 535 | /usr/lib/xorg/modules/dri /usr/lib32/xorg/modules/dri \
|
---|
| 536 | /usr/lib64/xorg/modules/dri /usr/lib/i386-linux-gnu/dri \
|
---|
| 537 | /usr/lib/x86_64-linux-gnu/dri; do
|
---|
| 538 | if [ -d $dir ]; then
|
---|
| 539 | rm -f "$dir/vboxvideo_dri.so" 2>/dev/null
|
---|
| 540 | fi
|
---|
| 541 | done
|
---|
[24410] | 542 |
|
---|
| 543 | # Remove VBoxClient autostart files
|
---|
| 544 | rm /etc/X11/Xsession.d/98vboxadd-xclient 2>/dev/null
|
---|
| 545 | rm /etc/X11/xinit.d/98vboxadd-xclient 2>/dev/null
|
---|
| 546 | rm /etc/X11/xinit/xinitrc.d/98vboxadd-xclient.sh 2>/dev/null
|
---|
| 547 | rm /etc/xdg/autostart/vboxclient.desktop 2>/dev/null
|
---|
| 548 | rm /usr/share/autostart/vboxclient.desktop 2>/dev/null
|
---|
[53383] | 549 | rm /usr/bin/VBoxClient-all 2>/dev/null
|
---|
[24410] | 550 |
|
---|
| 551 | # Remove other files
|
---|
| 552 | rm /usr/share/xserver-xorg/pci/vboxvideo.ids 2>/dev/null
|
---|
| 553 | }
|
---|
| 554 |
|
---|
| 555 | dmnstatus()
|
---|
| 556 | {
|
---|
[24950] | 557 | /bin/true
|
---|
[24410] | 558 | }
|
---|
| 559 |
|
---|
| 560 | case "$1" in
|
---|
| 561 | start)
|
---|
| 562 | start
|
---|
| 563 | ;;
|
---|
| 564 | stop)
|
---|
| 565 | stop
|
---|
| 566 | ;;
|
---|
| 567 | restart)
|
---|
| 568 | restart
|
---|
| 569 | ;;
|
---|
| 570 | setup)
|
---|
| 571 | setup
|
---|
| 572 | ;;
|
---|
| 573 | cleanup)
|
---|
| 574 | cleanup
|
---|
| 575 | ;;
|
---|
| 576 | status)
|
---|
| 577 | dmnstatus
|
---|
| 578 | ;;
|
---|
| 579 | *)
|
---|
| 580 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
| 581 | exit 1
|
---|
| 582 | esac
|
---|
| 583 |
|
---|
| 584 | exit
|
---|