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