vboxdrv.sh.in revision 4d84b0abe9a18ef4e6d8b7d97cf6fbfbfef1e5ed
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Oracle VM VirtualBox
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Linux kernel module init script
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Copyright (C) 2006-2010 Oracle Corporation
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# available from http://www.virtualbox.org. This file is free software;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# you can redistribute it and/or modify it under the terms of the GNU
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# General Public License (GPL) as published by the Free Software
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# chkconfig: 35 30 70
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# description: VirtualBox Linux kernel module
4651430e55b9df9726347e3e3968618e540fe729vboxsync### BEGIN INIT INFO
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync# Provides: vboxdrv
37e4655312fa6433c756cfa05a4db6b72e0c4344vboxsync# Required-Start: $syslog
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# Required-Stop:
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync# Default-Start: 2 3 4 5
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Default-Stop: 0 1 6
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync# Short-Description: VirtualBox Linux kernel module
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync### END INIT INFO
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncif $MODPROBE -c | grep -q '^allow_unsupported_modules *0'; then
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncif [ -n "$INSTALL_DIR" ]; then
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync BUILDVBOXDRV="$INSTALL_DIR/src/vboxhost/vboxdrv/build_in_tmp"
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync BUILDVBOXNETFLT="$INSTALL_DIR/src/vboxhost/vboxnetflt/build_in_tmp"
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync BUILDVBOXNETADP="$INSTALL_DIR/src/vboxhost/vboxnetadp/build_in_tmp"
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync BUILDVBOXPCI="$INSTALL_DIR/src/vboxhost/vboxpci/build_in_tmp"
231051c77670a4142b7545d51bd2251ae603189dvboxsync BUILDVBOXDRV="/usr/share/%PACKAGE%/src/vboxhost/vboxdrv/build_in_tmp"
231051c77670a4142b7545d51bd2251ae603189dvboxsync BUILDVBOXNETFLT="/usr/share/%PACKAGE%/src/vboxhost/vboxnetflt/build_in_tmp"
454ac5c6ef4960887035ceea6b5247789d3272davboxsync BUILDVBOXNETADP="/usr/share/%PACKAGE%/src/vboxhost/vboxnetadp/build_in_tmp"
89d62ba649bc933540aa6fecf95712eed480bcd2vboxsync BUILDVBOXPCI="/usr/share/%PACKAGE%/src/vboxhost/vboxpci/build_in_tmp"
76f5d3db08b007661ae4af93200838d24683af52vboxsync# silently exit if the package was uninstalled but not purged,
76f5d3db08b007661ae4af93200838d24683af52vboxsync# applies to Debian packages only
76f5d3db08b007661ae4af93200838d24683af52vboxsync[ -z "$DEBIAN" -o -x $VBOXMANAGE -a -x $BUILDVBOXDRV ] || exit 0
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncif [ -n "$NOLSB" ]; then
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync[ -r /etc/default/%PACKAGE% ] && . /etc/default/%PACKAGE%
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncif [ -z "$NOLSB" ]; then
9ff5b937cfc7a0832f0d8f52ab642193c2a0670avboxsync if [ -d /proc/xen ]; then
fbf482cad760a830bc8789ad639162019954ba80vboxsync failure "Running VirtualBox in a Xen environment is not supported"
fbf482cad760a830bc8789ad639162019954ba80vboxsync if ! rm -f $DEVICE; then
fbf482cad760a830bc8789ad639162019954ba80vboxsync failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
fbf482cad760a830bc8789ad639162019954ba80vboxsync if [ ! -c $DEVICE ]; then
fbf482cad760a830bc8789ad639162019954ba80vboxsync MAJOR=`sed -n 's;\([0-9]\+\) vboxdrv;\1;p' /proc/devices`
fbf482cad760a830bc8789ad639162019954ba80vboxsync MINOR=`sed -n 's;\([0-9]\+\) vboxdrv;\1;p' /proc/misc`
fbf482cad760a830bc8789ad639162019954ba80vboxsync if ! mknod -m 0660 $DEVICE c $MAJOR $MINOR 2>/dev/null; then
fbf482cad760a830bc8789ad639162019954ba80vboxsync failure "Cannot create device $DEVICE with major $MAJOR and minor $MINOR"
fbf482cad760a830bc8789ad639162019954ba80vboxsync failure "Cannot change group %GROUP% for device $DEVICE"
e96d318f28bf3515ea62273df31c0212313fa5abvboxsync if ! $MODPROBE vboxnetflt > /dev/null 2>&1; then
e96d318f28bf3515ea62273df31c0212313fa5abvboxsync failure "modprobe vboxnetflt failed. Please use 'dmesg' to find out why"
e96d318f28bf3515ea62273df31c0212313fa5abvboxsync if ! $MODPROBE vboxnetadp > /dev/null 2>&1; then
fbf482cad760a830bc8789ad639162019954ba80vboxsync failure "modprobe vboxnetadp failed. Please use 'dmesg' to find out why"
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync # Create the /dev/vboxusb directory if the host supports that method
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync # of USB access. The USB code checks for the existance of that path.
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync if ! rmmod vboxnetadp 2>/dev/null; then
7fa9b0ac0a9faf4aedbd3b53aa0cb2b81be99ee6vboxsync if ! rmmod vboxnetflt 2>/dev/null; then
454ac5c6ef4960887035ceea6b5247789d3272davboxsync if ! rm -f $DEVICE; then
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# enter the following variables in /etc/default/%PACKAGE%:
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# SHUTDOWN_USERS="foo bar"
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# check for running VMs of user foo and user bar
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# SHUTDOWN=poweroff
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# SHUTDOWN=acpibutton
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# SHUTDOWN=savestate
10d107ae26d5e0a2293a693fe270427c6d96ba7dvboxsync# select one of these shutdown methods for running VMs
b05c756b0ff8732063fb867b843dc8bb4d1b940cvboxsync # don't create the ipcd directory with wrong permissions!
ceec11f70ccba5b30ce0a34c66116a09155aeb6evboxsync if [ -d /tmp/.vbox-$i-ipc ]; then
a232d881522e92876b3870985382aee4d2d4f211vboxsync VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
if ! $BUILDVBOXDRV \
if ! $BUILDVBOXNETFLT \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
if ! $BUILDVBOXNETADP \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
if ! $BUILDVBOXPCI \
--use-module-symvers /tmp/vboxdrv-Module.symvers \
rm -f /etc/vbox/module_not_compiled
if running vboxnetflt; then
if running vboxnetadp; then
for i in $SHUTDOWN_USERS; do
stop && start