vboxadd-x11.sh revision fc7dbc2aa3165daebbc0754bd6e9018c4f3601ee
#
# Linux Additions X11 setup init script ($Revision$)
#
#
# Copyright (C) 2006-2010 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# chkconfig: 35 30 70
# description: VirtualBox Linux Additions kernel modules
#
### BEGIN INIT INFO
# Provides: vboxadd-x11
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Description: VirtualBox Linux Additions X11 setup
### END INIT INFO
CONFIG="config"
# Check architecture
cpu="x86"
;;
cpu="amd64"
else
fi
;;
esac
# Find the version of X installed
# The last of the three is for the X.org 6.7 included in Fedora Core 2
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'`
# Version of Redhat or Fedora installed. Needed for setting up selinux policy.
redhat_release=`cat /etc/redhat-release 2> /dev/null`
# - how many of these have ever been used?
/etc/X11/XF86Config /etc/XF86Config /usr/X11R6/etc/X11/XF86Config-4 \
/usr/X11R6/etc/X11/XF86Config /usr/X11R6/lib/X11/XF86Config-4 \
/usr/X11R6/lib/X11/XF86Config"
if [ -f /etc/arch-release ]; then
elif [ -f /etc/redhat-release ]; then
elif [ -f /etc/debian_version ]; then
elif [ -f /etc/SuSE-release ]; then
elif [ -f /etc/gentoo-release ]; then
else
fi
if [ "$system" = "arch" ]; then
}
}
stat_busy "$1"
}
fi
if [ "$system" = "redhat" ]; then
echo
}
echo
}
echo -n "$1"
}
fi
if [ "$system" = "suse" ]; then
rc_status -v
}
rc_status -v
}
echo -n "$1"
}
fi
if [ "$system" = "gentoo" ]; then
if [ -f /sbin/functions.sh ]; then
. /sbin/functions.sh
fi
eend 1
}
eend $?
}
ebegin $1
}
shift
fi
fi
if [ "$system" = "lfs" ]; then
}
}
echo $1
}
fi
echo " ...fail!"
}
echo " ...done."
}
echo -n $1
}
fi
group=1
fail()
{
eerror $1
exit 1
fi
echo "($1)"
exit 1
}
# Install an X11 desktop startup application. The application should be a shell script.
# Its name should be purely alphanumeric and should start with a two digit number (preferably
# 98 or thereabouts) to indicate its place in the Debian Xsession startup order.
#
# syntax: install_x11_startup_app app desktop service_name
self="install_x11_startup_app"
app_src=$1
desktop_src=$2
service_name=$3
alt_command=$4
found=0
then
install -m 0644 $app_src "$mandriva_dir/$app_dest"
found=1
fi
then
install -m 0644 $desktop_src "$x11_autostart/$desktop_dest"
found=1
fi
then
install -m 0644 $desktop_src "$kde_autostart/$desktop_dest"
found=1
fi
then
install -m 0644 $app_src "$redhat_dir/$app_dest"
found=1
fi
then
install -m 0755 $app_src "$debian_dir/$app_dest_sh"
found=1
fi
return 0
fi
Could not set up the $service_name desktop service.
To start it at log-in for a given user, add the command $alt_command
to the file .xinitrc in their home directory.
EOF
return 1
}
start()
{
# Todo: check configuration and correct it if necessary
return 0
}
stop()
{
return 0
}
restart()
{
stop && start
return 0
}
# setup_script
setup()
{
begin "Installing the Window System drivers"
fail "Invalid Guest Additions configuration found"
# By default we want to configure X
dox11config="true"
# By default, we want to run our xorg.conf setup script
setupxorgconf="true"
# But not to install the configuration file into xorg.conf.d
doxorgconfd=""
# But without the workaround for SUSE 11.1 not doing input auto-detection
newmouse=""
automouse="--autoMouse"
nopsaux="--nopsaux"
# The video driver to install for X.Org 6.9+
# The mouse driver to install for X.Org 6.9+
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
if [ -d $dir ]; then
break
fi
done
fi
echo
# advertise the fact.
case $x_version in 7.2.*)
x_version=1.3.0;;
esac
fi
case $x_version in
1.10.99.* )
echo "Warning: unsupported pre-release version of X.Org Server installed. Not"
echo "installing the X.Org drivers."
dox11config=""
;;
1.10.* )
doxorgconfd="true"
# Does Fedora still ship without vboxvideo detection?
# test "$system" = "redhat" || setupxorgconf=""
;;
1.9.99.901 )
echo "Warning: you are using a pre-release version of X.Org server 1.5 which is known"
echo "not to work with the VirtualBox Guest Additions. Please update to a more"
echo "recent version (for example by installing all updates in your guest) and then"
echo "set up the Guest Additions for X.Org server by running"
echo ""
echo " /usr/lib[64]/VBoxGuestAdditions/vboxadd-x11 setup"
dox11config=""
;;
1.9.99.* )
doxorgconfd="true"
# Does Fedora still ship without vboxvideo detection?
# test "$system" = "redhat" || setupxorgconf=""
;;
1.8.99.* | 1.9.* )
doxorgconfd="true"
# Fedora 14 looks likely to ship without vboxvideo detection
# test "$system" = "redhat" || setupxorgconf=""
;;
1.7.99.* | 1.8.* )
doxorgconfd="true"
# Fedora 13 shipped without vboxvideo detection
;;
1.6.99.* | 1.7.* )
;;
1.5.99.* | 1.6.* )
# SUSE with X.Org Server 1.6 knows about vboxvideo
;;
1.4.99.901 | 1.4.99.902 )
echo "Warning: you are using a pre-release version of X.Org server 1.5 which is known"
echo "not to work with the VirtualBox Guest Additions. Please update to a more"
echo "recent version (for example by installing all updates in your guest) and then"
echo "set up the Guest Additions for X.Org server by running"
echo ""
echo " /usr/lib[64]/VBoxGuestAdditions/vboxadd-x11 setup"
dox11config=""
;;
1.4.99.* | 1.5.* )
# Fedora 9 shipped X.Org Server version 1.4.99.9x (1.5.0 RC)
# in its released version
# SUSE with X.Org 1.5 is a special case, and is handled specially
;;
1.4.* )
automouse=""
newmouse="--newMouse"
;;
1.3.* )
# This was the first release which gave the server version number
# rather than the X11 release version when you did 'X -version'.
automouse=""
newmouse="--newMouse"
;;
7.1.* | 7.2.* )
automouse=""
;;
6.9.* | 7.0.* )
automouse=""
;;
6.7* | 6.8.* | 4.2.* | 4.3.* )
# Assume X.Org post-fork or XFree86
automouse=""
;;
* )
echo "Warning: unknown version of the X Window System installed. Not installing"
echo "X Window System drivers."
dox11config=""
;;
esac
fi
begin "Setting up the Window System to use the Guest Additions"
# video drivers. Some versions have the directory and don't use it.
# Those versions can autoload vboxvideo though, so we don't need to
# hack the configuration file for them.
{
rm -f "/usr/share/xserver-xorg/pci/vboxvideo.ids"
}
# Do the XF86Config/xorg.conf hack for those versions that require it
configured=""
generated=""
for i in $x11conf_files; do
if test -r "$i"; then
else
fi
configured="true"
fi
# Timestamp, so that we can see if the config file is changed
# by someone else later
done
# X.Org Server 1.5 and 1.6 can detect hardware they know, but they
# need a configuration file for VBoxVideo.
fi
fi
# X.Org Server versions starting with 1.5 can do mouse auto-detection,
# to make our lives easier and spare us the nasty hacks.
then
# Install hal information about the mouse driver so that X.Org
# knows to load it.
# Delete the hal cache so that it notices our fdi file
fi
if test -n "$doxorgconfd"
then
then
# This is normally silent. I have purposely not redirected
# error output as I want to know if something goes wrong,
# particularly if the command syntax ever changes.
fi
test -d /usr/share/X11/xorg.conf.d &&
test -d /usr/lib/X11/xorg.conf.d &&
test -d /etc/X11/xorg.conf.d &&
fi
cat << EOF
The following X.Org/XFree86 configuration files were originally generated by
the VirtualBox Guest Additions and were not modified:
$generated
EOF
cat << EOF
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.
EOF
fi
begin "Installing graphics libraries and desktop services components"
# Install selinux policy for Fedora 7 and 8 to allow the X server to
# open device files
;;
esac
# Install selinux policy for Fedora 8 to allow the X server to
# open our drivers
;;
esac
# Our logging code generates some glue code on 32-bit systems. At least F10
# completely irrelevant on the target system.
# Install the guest OpenGL drivers
then
rm -f /usr/lib64/dri/vboxvideo_dri.so
then
rm -f /usr/lib/dri/vboxvideo_dri.so
fi
then
then
fi
# And set up VBoxClient to start when the X session does
install_x11_startup_app "$lib_dir/98vboxadd-xclient" "$share_dir/vboxclient.desktop" VBoxClient VBoxClient-all ||
}
# cleanup_script
cleanup()
{
# Restore xorg.conf files as far as possible
## List of generated files which have been changed since we generated them
newer=""
## Are we dealing with a legacy information which didn't support
# uninstallation?
legacy=""
## Do any of the restored configuration files still reference our drivers?
failed=""
else
fi
else
for i in $x11conf_files; do
else
fi
fi
done
fi
The following X.Org/XFree86 configuration files were not restored, as they may
have been changed since they were generated by the VirtualBox Guest Additions.
You may wish to restore these manually. The file name in brackets is the
original version.
$newer
EOF
The following X.Org/XFree86 configuration files were restored, but still
contain references to the Guest Additions drivers. You may wish to check and
possibly correct the restored configuration files to be sure that the server
will continue to work after it is restarted.
$failed
EOF
# Remove X.Org drivers
# Remove the link to vboxvideo_dri.so
# Remove VBoxClient autostart files
# Remove other files
}
{
}
case "$1" in
;;
stop)
stop
;;
;;
;;
;;
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit