vboxadd.sh revision 674c51d0cb8c72a2852b315b70f76d11d82b20f5
# Sun VirtualBox
# Linux Additions kernel module init script ($Revision$)
#
#
# Copyright (C) 2006-2009 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: 357 30 70
# description: VirtualBox Linux Additions kernel modules
#
### BEGIN INIT INFO
# Provides: vboxadd
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: VirtualBox Linux Additions kernel modules
### END INIT INFO
fi
# Check architecture
cpu="x86"
;;
cpu="amd64"
else
fi
;;
esac
if [ -f /etc/arch-release ]; then
elif [ -f /etc/redhat-release ]; 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
if [ "$system" = "other" ]; then
echo " ...fail!"
}
echo " ...done."
}
echo -n $1
}
fi
group=1
{
return 0
fi
fi
printf "\nThe headers for the current running kernel were not found. If the following\nmodule compilation fails then this could be the reason.\n"
printf "The missing package can be probably installed with\napt-get install linux-headers-$KERN_VER\n"
fi
}
fail()
{
eerror $1
exit 1
fi
echo "($1)"
exit 1
}
{
}
{
}
{
}
start()
{
running_vboxguest || {
}
}
fail "modprobe vboxguest failed"
}
sleep .5
}
if [ ! -c $dev ]; then
min=0
else
maj=10
fi
fi
fail "Cannot locate the VirtualBox device"
}
}
fi
}
if [ ! -c $userdev ]; then
maj=10
}
}
fi
fi
running_vboxsf || {
echo "Unable to start shared folders support. Make sure that your VirtualBox build"
echo "supports this feature."
exit 1
fi
fail "modprobe vboxsf failed"
}
}
fi
# other startup script but this requires the vboxdrv kernel module loaded.
# This isn't necessary anymore as the vboxsf module is autoloaded.
# mount -a -t vboxsf
return 0
}
stop()
{
fail "Cannot unmount vboxsf folders"
fi
if running_vboxsf; then
fi
fi
if running_vboxguest; then
fi
return 0
}
restart()
{
stop && start
return 0
}
# setup_script
setup()
{
# don't stop the old modules here -- they might be in use
begin "Removing old VirtualBox vboxvideo kernel module"
fi
begin "Removing old VirtualBox vboxsf kernel module"
fi
begin "Removing old VirtualBox vboxguest kernel module"
fi
begin "Building the VirtualBox Guest Additions kernel modules"
printf "Your system does not seem to be set up to build kernel modules.\nLook at $LOG to find out what went wrong. Once you have corrected it, you can\nrun\n\n /etc/init.d/vboxadd setup\n\nto build them."
BUILDVBOXSF=""
else
printf "\nYour guest system does not seem to have sufficient OpenGL support to enable\naccelerated 3D effects (this requires Linux 2.6.27 or later in the guest\nsystem). This Guest Additions feature will be disabled.\n\n"
fi
fi
echo
begin "Building the main Guest Additions module"
if ! $BUILDVBOXGUEST \
fi
fi
begin "Building the shared folder support module"
if ! $BUILDVBOXSF \
--use-module-symvers /tmp/vboxguest-Module.symvers \
fi
fi
begin "Building the OpenGL support module"
if ! $BUILDVBOXVIDEO \
--use-module-symvers /tmp/vboxguest-Module.symvers \
fi
fi
begin "Doing non-kernel setup of the Guest Additions"
# This is the LSB version of useradd and should work on recent
# distributions
# And for the others, we choose a UID ourselves
# Add a group "vboxsf" for Shared Folders access
# All users which want to access the auto-mounted Shared Folders have to
# be added to this group.
# Create udev description file
udev_call=""
if [ $? -eq 0 ]; then
else
if [ $? -eq 0 ]; then
fi
fi
udev_fix="="
if [ "${udev_call}" != "" ]; then
udev_fix=""
fi
fi
## @todo 60-vboxadd.rules -> 60-vboxguest.rules ?
echo "KERNEL=${udev_fix}\"vboxguest\", NAME=\"vboxguest\", OWNER=\"vboxadd\", MODE=\"0660\"" > /etc/udev/rules.d/60-vboxadd.rules
echo "KERNEL=${udev_fix}\"vboxuser\", NAME=\"vboxuser\", OWNER=\"vboxadd\", MODE=\"0666\"" >> /etc/udev/rules.d/60-vboxadd.rules
fi
# Put mount.vboxsf in the right place
# At least Fedora 11 and Fedora 12 demand on the correct security context when
# executing this command from service scripts. Shouldn't hurt for other distributions.
if running_vboxguest || running_vboxadd; then
printf "You should restart your guest to make sure the new modules are actually used\n\n"
else
fi
fi
}
# cleanup_script
cleanup()
{
# Delete old versions of VBox modules.
echo "Attempt to remove old DKMS modules..."
fi
done
done
echo "Done."
fi
# Remove old installed modules
# Remove old module sources
rm -rf /usr/src/vboxadd-* /usr/src/vboxguest-* /usr/src/vboxvfs-* /usr/src/vboxsf-* /usr/src/vboxvideo-*
# Remove other files
rm /sbin/mount.vboxsf 2>/dev/null
}
{
if running_vboxguest; then
echo "The VirtualBox Additions are currently running."
else
echo "The VirtualBox Additions are not currently running."
fi
}
case "$1" in
;;
stop)
stop
;;
;;
;;
;;
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit