vboxdrv.sh.in revision 0898479d39425c8b56340334342ca4dcef3b87b3
# Oracle VM VirtualBox
# Linux kernel module init script
#
# Copyright (C) 2006-2013 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 20 80
# description: VirtualBox Linux kernel module
#
### BEGIN INIT INFO
# Provides: vboxdrv
# Required-Start: $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: VirtualBox Linux kernel module
### END INIT INFO
fi
export BUILD_TYPE
export USERNAME
if [ -n "$INSTALL_DIR" ]; then
VBOXMANAGE="$INSTALL_DIR/VBoxManage"
else
fi
BUILDINTMP="$MODULE_SRC/build_in_tmp"
DODKMS="$MODULE_SRC/do_dkms"
# silently exit if the package was uninstalled but not purged,
# applies to Debian packages only (but shouldn't hurt elsewhere)
if [ -n "$NOLSB" ]; then
if [ -f /etc/redhat-release ]; then
elif [ -f /etc/SuSE-release ]; then
elif [ -f /etc/gentoo-release ]; then
fi
fi
if [ -z "$NOLSB" ]; then
echo ""
log_failure_msg "$1"
}
}
log_daemon_msg "$@"
}
else
if [ "$system" = "redhat" ]; then
echo -n " "
echo
echo " ($1)"
}
echo -n " "
echo
}
elif [ "$system" = "suse" ]; then
rc_status -v
echo " ($1)"
}
rc_status -v
}
elif [ "$system" = "gentoo" ]; then
if [ -f /sbin/functions.sh ]; then
. /sbin/functions.sh
fi
eerror "$1"
}
eend "$?"
}
ebegin "$1"
}
shift
fi
else
echo " ...failed!"
echo " ($1)"
}
echo " ...done."
}
fi
if [ "$system" != "gentoo" ]; then
[ -z "${1:-}" ] && return 1
if [ -z "${2:-}" ]; then
echo -n "$1"
else
echo -n "$1: $2"
fi
}
fi
fi
failure()
{
fail_msg "$1"
exit 0
}
running()
{
}
start()
{
begin_msg "Starting VirtualBox kernel modules"
failure "Running VirtualBox in a Xen environment is not supported"
fi
fi
failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
fi
sleep .2
fi
# ensure the character special exists
if [ ! -c $DEVICE ]; then
MINOR=0
else
MAJOR=10
fi
fi
failure "Cannot locate the VirtualBox device"
fi
fi
fi
# ensure permissions
rmmod vboxnetadp 2>/dev/null
rmmod vboxnetflt 2>/dev/null
fi
if ! $MODPROBE vboxnetflt > /dev/null 2>&1; then
failure "modprobe vboxnetflt failed. Please use 'dmesg' to find out why"
fi
if ! $MODPROBE vboxnetadp > /dev/null 2>&1; then
failure "modprobe vboxnetadp failed. Please use 'dmesg' to find out why"
fi
failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
fi
# of USB access. The USB code checks for the existance of that path.
if grep -q usb_device /proc/devices; then
fi
}
stop()
{
begin_msg "Stopping VirtualBox kernel modules"
failure "Cannot unload module vboxpci"
fi
fi
if running vboxnetadp; then
if ! rmmod vboxnetadp 2>/dev/null; then
failure "Cannot unload module vboxnetadp"
fi
fi
if running vboxnetflt; then
if ! rmmod vboxnetflt 2>/dev/null; then
failure "Cannot unload module vboxnetflt"
fi
fi
failure "Cannot unload module vboxdrv"
fi
fi
fi
}
# enter the following variables in /etc/default/virtualbox:
# SHUTDOWN_USERS="foo bar"
# check for running VMs of user foo and user bar
# SHUTDOWN=poweroff
# SHUTDOWN=acpibutton
# SHUTDOWN=savestate
# select one of these shutdown methods for running VMs
stop_vms()
{
wait=0
for i in $SHUTDOWN_USERS; do
# don't create the ipcd directory with wrong permissions!
export VBOX_IPC_SOCKETID="$i"
begin_msg "Powering off remaining VMs"
done
begin_msg "Sending ACPI power button event to remaining VMs"
wait=30
done
begin_msg "Saving state of remaining VMs"
done
fi
fi
fi
done
# wait for some seconds when doing ACPI shutdown
fi
}
# setup_script
setup()
{
stop
begin_msg "Uninstalling old VirtualBox DKMS kernel modules"
fi
begin_msg "Removing old VirtualBox pci kernel module"
fi
begin_msg "Removing old VirtualBox netadp kernel module"
fi
begin_msg "Removing old VirtualBox netflt kernel module"
fi
begin_msg "Removing old VirtualBox kernel module"
fi
begin_msg "Trying to register the VirtualBox kernel modules using DKMS"
fail_msg "Failed, trying without DKMS"
DKMS=""
fi
fi
begin_msg "Recompiling VirtualBox kernel modules"
if ! $BUILDINTMP \
fi
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
fi
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
fi
if ! $BUILDINTMP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
fi
fi
rm -f /etc/vbox/module_not_compiled
}
{
str="vboxdrv"
if running vboxnetflt; then
if running vboxnetadp; then
fi
fi
fi
echo "VirtualBox kernel modules ($str) are loaded."
for i in $SHUTDOWN_USERS; do
# don't create the ipcd directory with wrong permissions!
export VBOX_IPC_SOCKETID="$i"
echo "The following VMs are currently running:"
echo " $v"
done
fi
fi
done
else
echo "VirtualBox kernel module is not loaded."
fi
}
case "$1" in
;;
stop)
stop
;;
;;
stop && start
;;
stop
;;
;;
;;
*)
echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status|setup}"
exit 1
esac
exit 0