vboxadd.sh revision 648515022dff7bf4e6b2efe376175cdafd6a9e00
#
# Linux Additions kernel module 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: 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
{
which make > /dev/null 2>&1 || printf "\nThe make utility was not found. If the following module compilation fails then\nthis could be the reason and you should try installing it.\n"
which gcc > /dev/null 2>&1 || printf "\nThe gcc utility was not found. If the following module compilation fails then\nthis could be the reason and you should try installing it.\n"
}
{
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\nzypper install kernel-$KERN_VER_SUSE-devel-$KERN_VER_BASE\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
}
{
}
{
}
{
}
{
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
}
start()
{
running_vboxguest || {
}
}
fail "modprobe vboxguest failed"
}
sleep .5;;
esac
}
esac
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
}
# Remove any existing VirtualBox guest kernel modules from the disk, but not
# from the kernel as they may still be in use
{
begin "Removing existing VirtualBox DKMS kernel modules"
begin "Removing existing VirtualBox non-DKMS kernel modules"
}
# Build and install the VirtualBox guest kernel modules
{
# don't stop the old modules here -- they might be in use
begin "Building the VirtualBox Guest Additions kernel modules"
# Short cut out if a dkms build succeeds
return 0
fi
echo
echo "Not building the VirtualBox advanced graphics driver as this Linux version is"
echo "too old to use it."
fi
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
return 0
}
# Do non-kernel bits needed for the kernel modules to work properly (user
# creation, udev, mount helper...)
{
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 require the correct security context when
# executing this command from service scripts. Shouldn't hurt for other
# distributions.
# And at least Fedora 15 needs this for the acceleration support check to
# work
redhat_release=`cat /etc/redhat-release 2> /dev/null`
do
done
;;
esac
}
# setup_script
setup()
{
mod_succ="$?"
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.
# 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|setup}"
exit 1
esac
exit