| 1 | #! /bin/sh
|
|---|
| 2 | # Sun VirtualBox
|
|---|
| 3 | # Linux Additions X11 setup init script ($Revision: 63031 $)
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (C) 2006-2009 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="/usr/lib"
|
|---|
| 42 | ;;
|
|---|
| 43 | x86_64|amd64)
|
|---|
| 44 | cpu="amd64"
|
|---|
| 45 | if test -d "/usr/lib64"; then
|
|---|
| 46 | LIB="/usr/lib64"
|
|---|
| 47 | else
|
|---|
| 48 | LIB="/usr/lib"
|
|---|
| 49 | fi
|
|---|
| 50 | ;;
|
|---|
| 51 | esac
|
|---|
| 52 |
|
|---|
| 53 | # Find the version of X installed
|
|---|
| 54 | # The last of the three is for the X.org 6.7 included in Fedora Core 2
|
|---|
| 55 | xver=`X -version 2>&1`
|
|---|
| 56 | 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'`
|
|---|
| 57 | # Version of Redhat or Fedora installed. Needed for setting up selinux policy.
|
|---|
| 58 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
|---|
| 59 | # All the different possible locations for XFree86/X.Org configuration files
|
|---|
| 60 | # - how many of these have ever been used?
|
|---|
| 61 | x11conf_files="/etc/X11/xorg.conf /etc/X11/xorg.conf-4 /etc/X11/.xorg.conf \
|
|---|
| 62 | /etc/xorg.conf /usr/etc/X11/xorg.conf-4 /usr/etc/X11/xorg.conf \
|
|---|
| 63 | /usr/lib/X11/xorg.conf-4 /usr/lib/X11/xorg.conf /etc/X11/XF86Config-4 \
|
|---|
| 64 | /etc/X11/XF86Config /etc/XF86Config /usr/X11R6/etc/X11/XF86Config-4 \
|
|---|
| 65 | /usr/X11R6/etc/X11/XF86Config /usr/X11R6/lib/X11/XF86Config-4 \
|
|---|
| 66 | /usr/X11R6/lib/X11/XF86Config"
|
|---|
| 67 |
|
|---|
| 68 | if [ -f /etc/arch-release ]; then
|
|---|
| 69 | system=arch
|
|---|
| 70 | elif [ -f /etc/redhat-release ]; then
|
|---|
| 71 | system=redhat
|
|---|
| 72 | elif [ -f /etc/debian_version ]; then
|
|---|
| 73 | system=debian
|
|---|
| 74 | elif [ -f /etc/SuSE-release ]; then
|
|---|
| 75 | system=suse
|
|---|
| 76 | elif [ -f /etc/gentoo-release ]; then
|
|---|
| 77 | system=gentoo
|
|---|
| 78 | elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
|
|---|
| 79 | system=lfs
|
|---|
| 80 | else
|
|---|
| 81 | system=other
|
|---|
| 82 | fi
|
|---|
| 83 |
|
|---|
| 84 | if [ "$system" = "arch" ]; then
|
|---|
| 85 | USECOLOR=yes
|
|---|
| 86 | . /etc/rc.d/functions
|
|---|
| 87 | fail_msg() {
|
|---|
| 88 | stat_fail
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | succ_msg() {
|
|---|
| 92 | stat_done
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | begin() {
|
|---|
| 96 | stat_busy "$1"
|
|---|
| 97 | }
|
|---|
| 98 | fi
|
|---|
| 99 |
|
|---|
| 100 | if [ "$system" = "redhat" ]; then
|
|---|
| 101 | . /etc/init.d/functions
|
|---|
| 102 | fail_msg() {
|
|---|
| 103 | echo_failure
|
|---|
| 104 | echo
|
|---|
| 105 | }
|
|---|
| 106 | succ_msg() {
|
|---|
| 107 | echo_success
|
|---|
| 108 | echo
|
|---|
| 109 | }
|
|---|
| 110 | begin() {
|
|---|
| 111 | echo -n "$1"
|
|---|
| 112 | }
|
|---|
| 113 | fi
|
|---|
| 114 |
|
|---|
| 115 | if [ "$system" = "suse" ]; then
|
|---|
| 116 | . /etc/rc.status
|
|---|
| 117 | fail_msg() {
|
|---|
| 118 | rc_failed 1
|
|---|
| 119 | rc_status -v
|
|---|
| 120 | }
|
|---|
| 121 | succ_msg() {
|
|---|
| 122 | rc_reset
|
|---|
| 123 | rc_status -v
|
|---|
| 124 | }
|
|---|
| 125 | begin() {
|
|---|
| 126 | echo -n "$1"
|
|---|
| 127 | }
|
|---|
| 128 | fi
|
|---|
| 129 |
|
|---|
| 130 | if [ "$system" = "gentoo" ]; then
|
|---|
| 131 | if [ -f /sbin/functions.sh ]; then
|
|---|
| 132 | . /sbin/functions.sh
|
|---|
| 133 | elif [ -f /etc/init.d/functions.sh ]; then
|
|---|
| 134 | . /etc/init.d/functions.sh
|
|---|
| 135 | fi
|
|---|
| 136 | fail_msg() {
|
|---|
| 137 | eend 1
|
|---|
| 138 | }
|
|---|
| 139 | succ_msg() {
|
|---|
| 140 | eend $?
|
|---|
| 141 | }
|
|---|
| 142 | begin() {
|
|---|
| 143 | ebegin $1
|
|---|
| 144 | }
|
|---|
| 145 | if [ "`which $0`" = "/sbin/rc" ]; then
|
|---|
| 146 | shift
|
|---|
| 147 | fi
|
|---|
| 148 | fi
|
|---|
| 149 |
|
|---|
| 150 | if [ "$system" = "lfs" ]; then
|
|---|
| 151 | . /etc/rc.d/init.d/functions
|
|---|
| 152 | fail_msg() {
|
|---|
| 153 | echo_failure
|
|---|
| 154 | }
|
|---|
| 155 | succ_msg() {
|
|---|
| 156 | echo_ok
|
|---|
| 157 | }
|
|---|
| 158 | begin() {
|
|---|
| 159 | echo $1
|
|---|
| 160 | }
|
|---|
| 161 | fi
|
|---|
| 162 |
|
|---|
| 163 | if [ "$system" = "debian" -o "$system" = "other" ]; then
|
|---|
| 164 | fail_msg() {
|
|---|
| 165 | echo " ...fail!"
|
|---|
| 166 | }
|
|---|
| 167 | succ_msg() {
|
|---|
| 168 | echo " ...done."
|
|---|
| 169 | }
|
|---|
| 170 | begin() {
|
|---|
| 171 | echo -n $1
|
|---|
| 172 | }
|
|---|
| 173 | fi
|
|---|
| 174 |
|
|---|
| 175 | dev=/dev/vboxguest
|
|---|
| 176 | userdev=/dev/vboxuser
|
|---|
| 177 | owner=vboxadd
|
|---|
| 178 | group=1
|
|---|
| 179 |
|
|---|
| 180 | fail()
|
|---|
| 181 | {
|
|---|
| 182 | if [ "$system" = "gentoo" ]; then
|
|---|
| 183 | eerror $1
|
|---|
| 184 | exit 1
|
|---|
| 185 | fi
|
|---|
| 186 | fail_msg
|
|---|
| 187 | echo "($1)"
|
|---|
| 188 | exit 1
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | # Install an X11 desktop startup application. The application should be a shell script.
|
|---|
| 192 | # Its name should be purely alphanumeric and should start with a two digit number (preferably
|
|---|
| 193 | # 98 or thereabouts) to indicate its place in the Debian Xsession startup order.
|
|---|
| 194 | #
|
|---|
| 195 | # syntax: install_x11_startup_app app desktop service_name
|
|---|
| 196 | install_x11_startup_app() {
|
|---|
| 197 | self="install_x11_startup_app"
|
|---|
| 198 | app_src=$1
|
|---|
| 199 | desktop_src=$2
|
|---|
| 200 | service_name=$3
|
|---|
| 201 | alt_command=$4
|
|---|
| 202 | test -r "$app_src" ||
|
|---|
| 203 | { echo >> $LOG "$self: no script given"; return 1; }
|
|---|
| 204 | test -r "$desktop_src" ||
|
|---|
| 205 | { echo >> $LOG "$self: no desktop file given"; return 1; }
|
|---|
| 206 | test -n "$service_name" ||
|
|---|
| 207 | { echo >> $LOG "$self: no service given"; return 1; }
|
|---|
| 208 | test -n "$alt_command" ||
|
|---|
| 209 | { echo >> $LOG "$self: no service given"; return 1; }
|
|---|
| 210 | app_dest=`basename $app_src sh`
|
|---|
| 211 | app_dest_sh=`basename $app_src sh`.sh
|
|---|
| 212 | desktop_dest=`basename $desktop_src`
|
|---|
| 213 | found=0
|
|---|
| 214 | x11_autostart="/etc/xdg/autostart"
|
|---|
| 215 | kde_autostart="/usr/share/autostart"
|
|---|
| 216 | redhat_dir=/etc/X11/Xsession.d
|
|---|
| 217 | mandriva_dir=/etc/X11/xinit.d
|
|---|
| 218 | debian_dir=/etc/X11/xinit/xinitrc.d
|
|---|
| 219 | if [ -d "$mandriva_dir" -a -w "$mandriva_dir" -a -x "$mandriva_dir" ]
|
|---|
| 220 | then
|
|---|
| 221 | install -m 0644 $app_src "$mandriva_dir/$app_dest"
|
|---|
| 222 | found=1
|
|---|
| 223 | fi
|
|---|
| 224 | if [ -d "$x11_autostart" -a -w "$x11_autostart" -a -x "$x11_autostart" ]
|
|---|
| 225 | then
|
|---|
| 226 | install -m 0644 $desktop_src "$x11_autostart/$desktop_dest"
|
|---|
| 227 | found=1
|
|---|
| 228 | fi
|
|---|
| 229 | if [ -d "$kde_autostart" -a -w "$kde_autostart" -a -x "$kde_autostart" ]
|
|---|
| 230 | then
|
|---|
| 231 | install -m 0644 $desktop_src "$kde_autostart/$desktop_dest"
|
|---|
| 232 | found=1
|
|---|
| 233 | fi
|
|---|
| 234 | if [ -d "$redhat_dir" -a -w "$redhat_dir" -a -x "$redhat_dir" ]
|
|---|
| 235 | then
|
|---|
| 236 | install -m 0644 $app_src "$redhat_dir/$app_dest"
|
|---|
| 237 | found=1
|
|---|
| 238 | fi
|
|---|
| 239 | if [ -d "$debian_dir" -a -w "$debian_dir" -a -x "$debian_dir" ]
|
|---|
| 240 | then
|
|---|
| 241 | install -m 0755 $app_src "$debian_dir/$app_dest_sh"
|
|---|
| 242 | found=1
|
|---|
| 243 | fi
|
|---|
| 244 | if [ $found -eq 1 ]; then
|
|---|
| 245 | return 0
|
|---|
| 246 | fi
|
|---|
| 247 | cat >> $LOG << EOF
|
|---|
| 248 | Could not set up the $service_name desktop service.
|
|---|
| 249 | To start it at log-in for a given user, add the command $alt_command
|
|---|
| 250 | to the file .xinitrc in their home directory.
|
|---|
| 251 | EOF
|
|---|
| 252 | return 1
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | start()
|
|---|
| 257 | {
|
|---|
| 258 | # Todo: check configuration and correct it if necessary
|
|---|
| 259 | return 0
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | stop()
|
|---|
| 263 | {
|
|---|
| 264 | return 0
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | restart()
|
|---|
| 268 | {
|
|---|
| 269 | stop && start
|
|---|
| 270 | return 0
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | # setup_script
|
|---|
| 274 | setup()
|
|---|
| 275 | {
|
|---|
| 276 | echo "VirtualBox Guest Additions installation, Window System and desktop setup" > $LOG
|
|---|
| 277 | begin "Installing the Window System drivers"
|
|---|
| 278 | lib_dir="$LIB/VBoxGuestAdditions"
|
|---|
| 279 | share_dir="/usr/share/VBoxGuestAdditions"
|
|---|
| 280 | test -x "$lib_dir" -a -x "$share_dir" ||
|
|---|
| 281 | fail "Invalid Guest Additions configuration found"
|
|---|
| 282 | # By default we want to configure X
|
|---|
| 283 | dox11config="true"
|
|---|
| 284 | # By default, we want to run our xorg.conf setup script
|
|---|
| 285 | setupxorgconf="true"
|
|---|
| 286 | # But not to install the configuration file into xorg.conf.d
|
|---|
| 287 | doxorgconfd=""
|
|---|
| 288 | # But without the workaround for SUSE 11.1 not doing input auto-detection
|
|---|
| 289 | newmouse=""
|
|---|
| 290 | # By default we want to use hal/udev/whatever for auto-loading the mouse driver
|
|---|
| 291 | automouse="--autoMouse"
|
|---|
| 292 | # We need to tell our xorg.conf hacking script whether /dev/psaux exists
|
|---|
| 293 | nopsaux="--nopsaux"
|
|---|
| 294 | test -c /dev/psaux && nopsaux=""
|
|---|
| 295 | # The video driver to install for X.Org 6.9+
|
|---|
| 296 | vboxvideo_src=
|
|---|
| 297 | # The mouse driver to install for X.Org 6.9+
|
|---|
| 298 | vboxmouse_src=
|
|---|
| 299 |
|
|---|
| 300 | modules_dir=`X -showDefaultModulePath 2>&1` || modules_dir=
|
|---|
| 301 | if [ -z "$modules_dir" ]; then
|
|---|
| 302 | 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
|
|---|
| 303 | if [ -d $dir ]; then
|
|---|
| 304 | modules_dir=$dir
|
|---|
| 305 | break
|
|---|
| 306 | fi
|
|---|
| 307 | done
|
|---|
| 308 | fi
|
|---|
| 309 |
|
|---|
| 310 | test -z "$x_version" -o -z "$modules_dir" &&
|
|---|
| 311 | fail "Could not find the X.Org or XFree86 Window System."
|
|---|
| 312 |
|
|---|
| 313 | echo
|
|---|
| 314 | case $x_version in
|
|---|
| 315 | 1.8.99.* )
|
|---|
| 316 | echo "Warning: unsupported pre-release version of X.Org Server installed. Not"
|
|---|
| 317 | echo "installing the X.Org drivers."
|
|---|
| 318 | dox11config=""
|
|---|
| 319 | ;;
|
|---|
| 320 | 1.7.99.* | 1.8.* )
|
|---|
| 321 | begin "Installing X.Org Server 1.8 modules"
|
|---|
| 322 | vboxvideo_src=vboxvideo_drv_18.so
|
|---|
| 323 | vboxmouse_src=vboxmouse_drv_18.so
|
|---|
| 324 | doxorgconfd="true"
|
|---|
| 325 | # Fedora 13 looks likely to ship without vboxvideo detection
|
|---|
| 326 | test "$system" = "redhat" || setupxorgconf=""
|
|---|
| 327 | ;;
|
|---|
| 328 | 1.6.99.* | 1.7.* )
|
|---|
| 329 | begin "Installing X.Org Server 1.7 modules"
|
|---|
| 330 | vboxvideo_src=vboxvideo_drv_17.so
|
|---|
| 331 | vboxmouse_src=vboxmouse_drv_17.so
|
|---|
| 332 | setupxorgconf=""
|
|---|
| 333 | test "$system" = "debian" && doxorgconfd="true"
|
|---|
| 334 | ;;
|
|---|
| 335 | 1.5.99.* | 1.6.* )
|
|---|
| 336 | begin "Installing X.Org Server 1.6 modules"
|
|---|
| 337 | vboxvideo_src=vboxvideo_drv_16.so
|
|---|
| 338 | vboxmouse_src=vboxmouse_drv_16.so
|
|---|
| 339 | # SUSE with X.Org Server 1.6 knows about vboxvideo
|
|---|
| 340 | test "$system" = "suse" && setupxorgconf=""
|
|---|
| 341 | ;;
|
|---|
| 342 | 1.4.99.901 | 1.4.99.902 )
|
|---|
| 343 | echo "Warning: you are using a pre-release version of X.Org server 1.5 which is known"
|
|---|
| 344 | echo "not to work with the VirtualBox Guest Additions. Please update to a more"
|
|---|
| 345 | echo "recent version (for example by installing all updates in your guest) and then"
|
|---|
| 346 | echo "set up the Guest Additions for X.Org server by running"
|
|---|
| 347 | echo ""
|
|---|
| 348 | echo " /usr/lib[64]/VBoxGuestAdditions/vboxadd-x11 setup"
|
|---|
| 349 | dox11config=""
|
|---|
| 350 | ;;
|
|---|
| 351 | 1.4.99.* | 1.5.* )
|
|---|
| 352 | # Fedora 9 shipped X.Org Server version 1.4.99.9x (1.5.0 RC)
|
|---|
| 353 | # in its released version
|
|---|
| 354 | begin "Installing X.Org Server 1.5 modules"
|
|---|
| 355 | vboxvideo_src=vboxvideo_drv_15.so
|
|---|
| 356 | vboxmouse_src=vboxmouse_drv_15.so
|
|---|
| 357 | # SUSE with X.Org 1.5 is a special case, and is handled specially
|
|---|
| 358 | test "$system" = "suse" &&
|
|---|
| 359 | { automouse=""; newmouse="--newMouse"; }
|
|---|
| 360 | ;;
|
|---|
| 361 | 1.4.* )
|
|---|
| 362 | begin "Installing X.Org Server 1.4 modules"
|
|---|
| 363 | vboxvideo_src=vboxvideo_drv_14.so
|
|---|
| 364 | vboxmouse_src=vboxmouse_drv_14.so
|
|---|
| 365 | automouse=""
|
|---|
| 366 | newmouse="--newMouse"
|
|---|
| 367 | ;;
|
|---|
| 368 | 1.3.* )
|
|---|
| 369 | # This was the first release which gave the server version number
|
|---|
| 370 | # rather than the X11 release version when you did 'X -version'.
|
|---|
| 371 | begin "Installing X.Org Server 1.3 modules"
|
|---|
| 372 | vboxvideo_src=vboxvideo_drv_13.so
|
|---|
| 373 | vboxmouse_src=vboxmouse_drv_13.so
|
|---|
| 374 | automouse=""
|
|---|
| 375 | newmouse="--newMouse"
|
|---|
| 376 | ;;
|
|---|
| 377 | 7.1.* | 7.2.* )
|
|---|
| 378 | begin "Installing X.Org 7.1 modules"
|
|---|
| 379 | vboxvideo_src=vboxvideo_drv_71.so
|
|---|
| 380 | vboxmouse_src=vboxmouse_drv_71.so
|
|---|
| 381 | automouse=""
|
|---|
| 382 | ;;
|
|---|
| 383 | 6.9.* | 7.0.* )
|
|---|
| 384 | begin "Installing X.Org 6.9/7.0 modules"
|
|---|
| 385 | vboxvideo_src=vboxvideo_drv_70.so
|
|---|
| 386 | vboxmouse_src=vboxmouse_drv_70.so
|
|---|
| 387 | automouse=""
|
|---|
| 388 | ;;
|
|---|
| 389 | 6.7* | 6.8.* | 4.2.* | 4.3.* )
|
|---|
| 390 | # Assume X.Org post-fork or XFree86
|
|---|
| 391 | begin "Installing XFree86 4.2/4.3 and X.Org 6.7/6.8 modules"
|
|---|
| 392 | rm "$modules_dir/drivers/vboxvideo_drv.o" 2>/dev/null
|
|---|
| 393 | rm "$modules_dir/input/vboxmouse_drv.o" 2>/dev/null
|
|---|
| 394 | ln -s "$lib_dir/vboxvideo_drv.o" "$modules_dir/drivers/vboxvideo_drv.o"
|
|---|
| 395 | ln -s "$lib_dir/vboxmouse_drv.o" "$modules_dir/input/vboxmouse_drv.o"
|
|---|
| 396 | automouse=""
|
|---|
| 397 | succ_msg
|
|---|
| 398 | ;;
|
|---|
| 399 | * )
|
|---|
| 400 | echo "Warning: unknown version of the X Window System installed. Not installing"
|
|---|
| 401 | echo "X Window System drivers."
|
|---|
| 402 | dox11config=""
|
|---|
| 403 | ;;
|
|---|
| 404 | esac
|
|---|
| 405 | if [ -n "$vboxvideo_src" -a -n "$vboxmouse_src" ]; then
|
|---|
| 406 | rm "$modules_dir/drivers/vboxvideo_drv.so" 2>/dev/null
|
|---|
| 407 | rm "$modules_dir/input/vboxmouse_drv.so" 2>/dev/null
|
|---|
| 408 | ln -s "$lib_dir/$vboxvideo_src" "$modules_dir/drivers/vboxvideo_drv.so"
|
|---|
| 409 | ln -s "$lib_dir/$vboxmouse_src" "$modules_dir/input/vboxmouse_drv.so" &&
|
|---|
| 410 | succ_msg
|
|---|
| 411 | fi
|
|---|
| 412 |
|
|---|
| 413 | if test -n "$dox11config"; then
|
|---|
| 414 | begin "Setting up the Window System to use the Guest Additions"
|
|---|
| 415 | # Certain Ubuntu/Debian versions use a special PCI-id file to identify
|
|---|
| 416 | # video drivers. Some versions have the directory and don't use it.
|
|---|
| 417 | # Those versions can autoload vboxvideo though, so we don't need to
|
|---|
| 418 | # hack the configuration file for them.
|
|---|
| 419 | test "$system" = "debian" -a -d /usr/share/xserver-xorg/pci &&
|
|---|
| 420 | {
|
|---|
| 421 | rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
|
|---|
| 422 | ln -s "$share_dir/vboxvideo.ids" /usr/share/xserver-xorg/pci 2>/dev/null
|
|---|
| 423 | test -n "$automouse" && setupxorgconf=""
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | # Do the XF86Config/xorg.conf hack for those versions that require it
|
|---|
| 427 | configured=""
|
|---|
| 428 | generated=""
|
|---|
| 429 | if test -n "$setupxorgconf"; then
|
|---|
| 430 | for i in $x11conf_files; do
|
|---|
| 431 | if test -r "$i"; then
|
|---|
| 432 | if grep -q "VirtualBox generated" "$i"; then
|
|---|
| 433 | generated="$generated `printf "$i\n"`"
|
|---|
| 434 | else
|
|---|
| 435 | "$lib_dir/x11config-new.pl" $newmouse $automouse $nopsaux "$i"
|
|---|
| 436 | fi
|
|---|
| 437 | configured="true"
|
|---|
| 438 | fi
|
|---|
| 439 | # Timestamp, so that we can see if the config file is changed
|
|---|
| 440 | # by someone else later
|
|---|
| 441 | test -r "$i.vbox" && touch "$i.vbox"
|
|---|
| 442 | done
|
|---|
| 443 | # X.Org Server 1.5 and 1.6 can detect hardware they know, but they
|
|---|
| 444 | # need a configuration file for VBoxVideo.
|
|---|
| 445 | main_cfg="/etc/X11/xorg.conf"
|
|---|
| 446 | nobak="/etc/X11/xorg.vbox.nobak"
|
|---|
| 447 | if test -z "$configured"; then
|
|---|
| 448 | touch "$main_cfg"
|
|---|
| 449 | "$lib_dir/x11config-new.pl" $newmouse $automouse $nopsaux --noBak "$main_cfg"
|
|---|
| 450 | touch "$nobak"
|
|---|
| 451 | fi
|
|---|
| 452 | fi
|
|---|
| 453 | # X.Org Server versions starting with 1.5 can do mouse auto-detection,
|
|---|
| 454 | # to make our lives easier and spare us the nasty hacks.
|
|---|
| 455 | test -n "$automouse" &&
|
|---|
| 456 | if [ -d /etc/hal/fdi/policy ]
|
|---|
| 457 | then
|
|---|
| 458 | # Install hal information about the mouse driver so that X.Org
|
|---|
| 459 | # knows to load it.
|
|---|
| 460 | install -o 0 -g 0 -m 0644 "$share_dir/90-vboxguest.fdi" /etc/hal/fdi/policy
|
|---|
| 461 | # Delete the hal cache so that it notices our fdi file
|
|---|
| 462 | rm -r /var/cache/hald/fdi-cache 2> /dev/null
|
|---|
| 463 | fi
|
|---|
| 464 | if test -n "$doxorgconfd"
|
|---|
| 465 | then
|
|---|
| 466 | if test -d /etc/udev/rules.d
|
|---|
| 467 | then
|
|---|
| 468 | install -o 0 -g 0 -m 0644 "$share_dir/70-xorg-vboxmouse.rules" /etc/udev/rules.d
|
|---|
| 469 | # This is normally silent. I have purposely not redirected
|
|---|
| 470 | # error output as I want to know if something goes wrong,
|
|---|
| 471 | # particularly if the command syntax ever changes.
|
|---|
| 472 | udevadm trigger --action=change
|
|---|
| 473 | fi
|
|---|
| 474 | test -d /usr/share/X11/xorg.conf.d &&
|
|---|
| 475 | install -o 0 -g 0 -m 0644 "$share_dir/50-vboxmouse.conf" /usr/share/X11/xorg.conf.d
|
|---|
| 476 | test -d /usr/lib/X11/xorg.conf.d &&
|
|---|
| 477 | install -o 0 -g 0 -m 0644 "$share_dir/50-vboxmouse.conf" /usr/lib/X11/xorg.conf.d
|
|---|
| 478 | test -d /etc/X11/xorg.conf.d &&
|
|---|
| 479 | install -o 0 -g 0 -m 0644 "$share_dir/50-vboxmouse.conf" /etc/X11/xorg.conf.d
|
|---|
| 480 | fi
|
|---|
| 481 | succ_msg
|
|---|
| 482 | test -n "$generated" &&
|
|---|
| 483 | cat << EOF
|
|---|
| 484 | The following X.Org/XFree86 configuration files were originally generated by
|
|---|
| 485 | the VirtualBox Guest Additions and were not modified:
|
|---|
| 486 |
|
|---|
| 487 | $generated
|
|---|
| 488 |
|
|---|
| 489 | EOF
|
|---|
| 490 | cat << EOF
|
|---|
| 491 | You may need to restart the hal service and the Window System (or just restart
|
|---|
| 492 | the guest system) to enable the Guest Additions.
|
|---|
| 493 |
|
|---|
| 494 | EOF
|
|---|
| 495 | fi
|
|---|
| 496 |
|
|---|
| 497 | begin "Installing graphics libraries and desktop services components"
|
|---|
| 498 | # Install selinux policy for Fedora 7 and 8 to allow the X server to
|
|---|
| 499 | # open device files
|
|---|
| 500 | case "$redhat_release" in
|
|---|
| 501 | Fedora\ release\ 7* | Fedora\ release\ 8* )
|
|---|
| 502 | semodule -i "$share_dir/vbox_x11.pp" > /dev/null 2>&1
|
|---|
| 503 | ;;
|
|---|
| 504 | esac
|
|---|
| 505 |
|
|---|
| 506 | # Install selinux policy for Fedora 8 to allow the X server to
|
|---|
| 507 | # open our drivers
|
|---|
| 508 | case "$redhat_release" in
|
|---|
| 509 | Fedora\ release\ 8* )
|
|---|
| 510 | chcon -u system_u -t lib_t "$lib_dir"/*.so
|
|---|
| 511 | ;;
|
|---|
| 512 | esac
|
|---|
| 513 |
|
|---|
| 514 | # Our logging code generates some glue code on 32-bit systems. At least F10
|
|---|
| 515 | # needs a rule to allow this. Send all output to /dev/null in case this is
|
|---|
| 516 | # completely irrelevant on the target system.
|
|---|
| 517 | chcon -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
|---|
| 518 | semanage fcontext -a -t unconfined_execmem_exec_t '/usr/bin/VBoxClient' > /dev/null 2>&1
|
|---|
| 519 | # Install the guest OpenGL drivers
|
|---|
| 520 | if [ -d /usr/lib64/dri ]
|
|---|
| 521 | then
|
|---|
| 522 | rm -f /usr/lib64/dri/vboxvideo_dri.so
|
|---|
| 523 | ln -s $LIB/VBoxOGL.so /usr/lib64/dri/vboxvideo_dri.so
|
|---|
| 524 | elif [ -d /usr/lib/dri ]
|
|---|
| 525 | then
|
|---|
| 526 | rm -f /usr/lib/dri/vboxvideo_dri.so
|
|---|
| 527 | ln -s $LIB/VBoxOGL.so /usr/lib/dri/vboxvideo_dri.so
|
|---|
| 528 | fi
|
|---|
| 529 | if [ -d /usr/lib64/xorg/modules/dri ]
|
|---|
| 530 | then
|
|---|
| 531 | rm -f /usr/lib64/xorg/modules/dri/vboxvideo_dri.so
|
|---|
| 532 | ln -s $LIB/VBoxOGL.so /usr/lib64/xorg/modules/dri/vboxvideo_dri.so
|
|---|
| 533 | elif [ -d /usr/lib/xorg/modules/dri ]
|
|---|
| 534 | then
|
|---|
| 535 | rm -f /usr/lib/xorg/modules/dri/vboxvideo_dri.so
|
|---|
| 536 | ln -s $LIB/VBoxOGL.so /usr/lib/xorg/modules/dri/vboxvideo_dri.so
|
|---|
| 537 | fi
|
|---|
| 538 |
|
|---|
| 539 | # And set up VBoxClient to start when the X session does
|
|---|
| 540 | install_x11_startup_app "$lib_dir/98vboxadd-xclient" "$share_dir/vboxclient.desktop" VBoxClient VBoxClient-all ||
|
|---|
| 541 | fail "See the log file $LOG for more information."
|
|---|
| 542 | succ_msg
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 | # cleanup_script
|
|---|
| 546 | cleanup()
|
|---|
| 547 | {
|
|---|
| 548 | # Restore xorg.conf files as far as possible
|
|---|
| 549 | ## List of generated files which have been changed since we generated them
|
|---|
| 550 | newer=""
|
|---|
| 551 | ## Are we dealing with a legacy information which didn't support
|
|---|
| 552 | # uninstallation?
|
|---|
| 553 | legacy=""
|
|---|
| 554 | ## Do any of the restored configuration files still reference our drivers?
|
|---|
| 555 | failed=""
|
|---|
| 556 | test -r "$CONFIG_DIR/$CONFIG" || legacy="true"
|
|---|
| 557 | main_cfg="/etc/X11/xorg.conf"
|
|---|
| 558 | nobak="/etc/X11/xorg.vbox.nobak"
|
|---|
| 559 | if test -r "$nobak"; then
|
|---|
| 560 | test -r "$main_cfg" &&
|
|---|
| 561 | if test -n "$legacy" -o ! "$nobak" -ot "$main_cfg"; then
|
|---|
| 562 | rm -f "$nobak" "$main_cfg"
|
|---|
| 563 | else
|
|---|
| 564 | newer="$newer`printf " $main_cfg (no original)\n"`"
|
|---|
| 565 | fi
|
|---|
| 566 | else
|
|---|
| 567 | for i in $x11conf_files; do
|
|---|
| 568 | if test -r "$i.vbox"; then
|
|---|
| 569 | if test ! "$i" -nt "$i.vbox" -o -n "$legacy"; then
|
|---|
| 570 | mv -f "$i.vbox" "$i"
|
|---|
| 571 | grep -q -E 'vboxvideo|vboxmouse' "$i" &&
|
|---|
| 572 | failed="$failed`printf " $i\n"`"
|
|---|
| 573 | else
|
|---|
| 574 | newer="$newer`printf " $i ($i.vbox)\n"`"
|
|---|
| 575 | fi
|
|---|
| 576 | fi
|
|---|
| 577 | done
|
|---|
| 578 | fi
|
|---|
| 579 | test -n "$newer" && cat << EOF
|
|---|
| 580 |
|
|---|
| 581 | The following X.Org/XFree86 configuration files were not restored, as they may
|
|---|
| 582 | have been changed since they were generated by the VirtualBox Guest Additions.
|
|---|
| 583 | You may wish to restore these manually. The file name in brackets is the
|
|---|
| 584 | original version.
|
|---|
| 585 |
|
|---|
| 586 | $newer
|
|---|
| 587 |
|
|---|
| 588 | EOF
|
|---|
| 589 | test -n "$failed" && cat << EOF
|
|---|
| 590 |
|
|---|
| 591 | The following X.Org/XFree86 configuration files were restored, but still
|
|---|
| 592 | contain references to the Guest Additions drivers. You may wish to check and
|
|---|
| 593 | possibly correct the restored configuration files to be sure that the server
|
|---|
| 594 | will continue to work after it is restarted.
|
|---|
| 595 |
|
|---|
| 596 | $failed
|
|---|
| 597 |
|
|---|
| 598 | EOF
|
|---|
| 599 |
|
|---|
| 600 | # Remove X.Org drivers
|
|---|
| 601 | find "$x11_modules_dir" /usr/lib64/xorg/modules /usr/lib/xorg/modules \
|
|---|
| 602 | /usr/X11R6/lib64/modules /usr/X11R6/lib/modules \
|
|---|
| 603 | /usr/X11R6/lib/X11/modules \
|
|---|
| 604 | '(' -name 'vboxvideo_drv*' -o -name 'vboxmouse_drv*' ')' \
|
|---|
| 605 | -exec rm -f '{}' ';' 2>/dev/null
|
|---|
| 606 |
|
|---|
| 607 | # Remove the link to vboxvideo_dri.so
|
|---|
| 608 | rm -f /usr/lib/dri/vboxvideo_dri.so /usr/lib64/dri/vboxvideo_dri.so 2>/dev/null
|
|---|
| 609 |
|
|---|
| 610 | # Remove VBoxClient autostart files
|
|---|
| 611 | rm /etc/X11/Xsession.d/98vboxadd-xclient 2>/dev/null
|
|---|
| 612 | rm /etc/X11/xinit.d/98vboxadd-xclient 2>/dev/null
|
|---|
| 613 | rm /etc/X11/xinit/xinitrc.d/98vboxadd-xclient.sh 2>/dev/null
|
|---|
| 614 | rm /etc/xdg/autostart/vboxclient.desktop 2>/dev/null
|
|---|
| 615 | rm /usr/share/autostart/vboxclient.desktop 2>/dev/null
|
|---|
| 616 |
|
|---|
| 617 | # Remove other files
|
|---|
| 618 | rm /etc/hal/fdi/policy/90-vboxguest.fdi 2>/dev/null
|
|---|
| 619 | rm /etc/udev/rules.d/70-xorg-vboxmouse.rules 2>/dev/null
|
|---|
| 620 | udevadm trigger --action=change 2>/dev/null
|
|---|
| 621 | rm /usr/lib/X11/xorg.conf.d/50-vboxmouse.conf 2>/dev/null
|
|---|
| 622 | rm /usr/share/X11/xorg.conf.d/50-vboxmouse.conf 2>/dev/null
|
|---|
| 623 | rm /usr/share/xserver-xorg/pci/vboxvideo.ids 2>/dev/null
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | dmnstatus()
|
|---|
| 627 | {
|
|---|
| 628 | /bin/true
|
|---|
| 629 | }
|
|---|
| 630 |
|
|---|
| 631 | case "$1" in
|
|---|
| 632 | start)
|
|---|
| 633 | start
|
|---|
| 634 | ;;
|
|---|
| 635 | stop)
|
|---|
| 636 | stop
|
|---|
| 637 | ;;
|
|---|
| 638 | restart)
|
|---|
| 639 | restart
|
|---|
| 640 | ;;
|
|---|
| 641 | setup)
|
|---|
| 642 | setup
|
|---|
| 643 | ;;
|
|---|
| 644 | cleanup)
|
|---|
| 645 | cleanup
|
|---|
| 646 | ;;
|
|---|
| 647 | status)
|
|---|
| 648 | dmnstatus
|
|---|
| 649 | ;;
|
|---|
| 650 | *)
|
|---|
| 651 | echo "Usage: $0 {start|stop|restart|status}"
|
|---|
| 652 | exit 1
|
|---|
| 653 | esac
|
|---|
| 654 |
|
|---|
| 655 | exit
|
|---|