vboxadd.sh revision bc04e4cfbb35893dd91b43c52d7f50f824131172
#
# Linux Additions kernel module init script ($Revision$)
#
#
# Copyright (C) 2006-2012 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
OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
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
{
eerror $1
fi
echo "($1)"
}
fail()
{
show_error "$1"
exit 1
}
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\nyum install kernel-uek-devel-$KERN_VER\n"
else
fi
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
}
{
}
{
}
{
}
{
}
{
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()
{
no_udev=1
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"
}
}
# This is needed as X.Org Server 1.13 does not auto-load the module.
running_vboxvideo || $MODPROBE vboxvideo > /dev/null 2>&1
# 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
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"
fi
begin "Removing existing VirtualBox non-DKMS kernel modules"
for i in $OLDMODULES; do
done
}
# 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
$DODKMS install vboxguest $INSTALL_VER >> $LOG 2>&1; then
return 0
fi
echo
begin "Building the main Guest Additions module"
if ! $BUILDINTMP \
--module-source $MODULE_SRC/vboxguest \
show_error "Look at $LOG to find out what went wrong"
return 1
fi
begin "Building the shared folder support module"
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxguest-Module.symvers \
--module-source $MODULE_SRC/vboxsf \
show_error "Look at $LOG to find out what went wrong"
return 1
fi
echo "Not building the VirtualBox advanced graphics driver as this Linux version is"
echo "too old to use it."
else
begin "Building the OpenGL support module"
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxguest-Module.symvers \
--module-source $MODULE_SRC/vboxvideo \
show_error "Look at $LOG to find out what went wrong"
return 1
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()
{
if test -r $config; then
. $config
else
fi
export BUILD_TYPE
export USERNAME
BUILDINTMP="$MODULE_SRC/build_in_tmp"
DODKMS="$MODULE_SRC/do_dkms"
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()
{
if test -r $config; then
. $config
DODKMS="$INSTALL_DIR/src/vboxguest-$INSTALL_VER/do_dkms"
elif test -x ./do_dkms; then # Executing as part of the installer...
else
fi
# Delete old versions of VBox modules.
# Remove old module sources
for i in $OLDMODULES; do
done
# 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