Index: /trunk/src/VBox/Installer/linux/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Installer/linux/Makefile.kmk	(revision 58011)
+++ /trunk/src/VBox/Installer/linux/Makefile.kmk	(revision 58012)
@@ -53,11 +53,8 @@
 	$(addprefix $(VBOX_LNX_INST_STAGE_DIR)/,\
 		install.sh \
-		vboxdrv.sh \
 		VirtualBox.tar.bz2 \
 		LICENSE) \
 	$(wildcard $(VBOX_LNX_INST_OUT_DIR)/VirtualBox-*) \
-	$(addprefix $(VBOX_LNX_INST_OUT_DIR)/,\
-		vboxdrv.sh \
-		install.sh)
+	$(VBOX_LNX_INST_OUT_DIR)/install.sh
 
 #
@@ -77,4 +74,5 @@
 	vboxballoonctrl-service.sh \
 	VBoxCreateUSBNode.sh \
+	vboxdrv.sh \
 	vboxweb-service.sh \
 	VBox.sh=>VBox.sh \
@@ -92,4 +90,5 @@
 	vboxautostart-service.sh \
 	vboxballoonctrl-service.sh \
+	vboxdrv.sh \
 	vboxweb-service.sh
 
@@ -364,5 +363,4 @@
 		$(VBOX_VERSION_STAMP) \
 		$(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)) \
-		$(VBOX_LNX_INST_OUT_DIR)/vboxdrv.sh \
 		$(VBOX_LNX_INST_OUT_DIR)/install.sh \
 		$(VBOX_PATH_LNX_INST_SRC)/installer-common.sh \
@@ -371,28 +369,8 @@
 	$(QUIET)$(RM) -f $(wildcard $(PATH_STAGE_BIN)/VirtualBox-*.run)
 	$(QUIET)$(if $(VBOX_OSE),,$(INSTALL) -m 0644 $(VBOX_BRAND_LICENSE_TXT)    $(VBOX_LNX_INST_STAGE_DIR)/LICENSE)
-	$(QUIET)$(INSTALL) -m 0755 $(VBOX_LNX_INST_OUT_DIR)/vboxdrv.sh            $(VBOX_LNX_INST_STAGE_DIR)/
 	$(QUIET)$(INSTALL) -m 0755 $(VBOX_LNX_INST_OUT_DIR)/install.sh            $(VBOX_LNX_INST_STAGE_DIR)/
 	$(QUIET)$(RM) -f $@
 	$(QUIET)$(VBOX_MAKESELF) --follow --nocomp $(VBOX_LNX_INST_STAGE_DIR) $@ \
 		"VirtualBox for Linux installation" ./install.sh "\$$0 1> /dev/null"
-
-# files that needs editing before they can be included in the generic installer.
-$(VBOX_LNX_INST_OUT_DIR)/vboxdrv.sh: $(VBOX_PATH_LNX_INST_SRC)/vboxdrv.sh.in | $$(dir $$@)
-	$(QUIET)$(SED_EXT) \
-		-e "s|%NOLSB%|yes|g" \
-		-e "s|%DEBIAN%||g" \
-		-e "s|%PACKAGE%|virtualbox|g" \
-		-e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
-		-e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
-		--output $@ \
-		$<
-
-$(PATH_STAGE_BIN)/vboxdrv.sh: $(VBOX_PATH_LNX_INST_SRC)/vboxdrv.sh.in | $$(dir $$@)
-	$(QUIET)$(SED_EXT) \
-		-e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
-		-e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
-		--output $@ \
-		$<
-	$(QUIET)$(CHMOD) 0755 $@
 
 $(VBOX_LNX_INST_OUT_DIR)/install.sh: $(VBOX_PATH_LNX_INST_SRC)/install.sh $(VBOX_PATH_LNX_INST_SRC)/installer-common.sh $(VBOX_VERSION_STAMP) $(VBOX_SVN_REV_KMK).ts | $$(dir $$@)
Index: /trunk/src/VBox/Installer/linux/debian/rules
===================================================================
--- /trunk/src/VBox/Installer/linux/debian/rules	(revision 58011)
+++ /trunk/src/VBox/Installer/linux/debian/rules	(revision 58012)
@@ -245,11 +245,5 @@
 	dh_desktop
 	$(if $(NOMODS),,dh_installmodules)
-	sed \
-	    -e 's|%NOLSB%||g' \
-	    -e 's|%DEBIAN%|yes|g' \
-	    -e 's|%PACKAGE%|virtualbox|g' \
-	    -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
-	    -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
-	    $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > $(prefix)/usr/lib/$(package)/vboxdrv.sh
+	cp $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh $(prefix)/usr/lib/$(package)
 	cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh $(prefix)/usr/lib/$(package)
 	cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh $(prefix)/usr/lib/$(package)
Index: /trunk/src/VBox/Installer/linux/rpm/rules
===================================================================
--- /trunk/src/VBox/Installer/linux/rpm/rules	(revision 58011)
+++ /trunk/src/VBox/Installer/linux/rpm/rules	(revision 58012)
@@ -243,11 +243,5 @@
 	    -e '}' \
 	    rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
-	sed \
-	    -e 's|%NOLSB%|yes|g' \
-	    -e 's|%DEBIAN%||g' \
-	    -e 's|%PACKAGE%|virtualbox|g' \
-	    -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
-	    -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
-	    vboxdrv.sh.in > $(archdir)/vboxdrv.sh
+	cp vboxdrv.sh $(archdir)
 	cp vboxballoonctrl-service.sh $(archdir)
 	cp vboxautostart-service.sh $(archdir)
Index: /trunk/src/VBox/Installer/linux/vboxdrv.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/vboxdrv.sh	(revision 58012)
+++ /trunk/src/VBox/Installer/linux/vboxdrv.sh	(revision 58012)
@@ -0,0 +1,351 @@
+#! /bin/sh
+# Oracle VM VirtualBox
+# Linux kernel module init script
+
+#
+# Copyright (C) 2006-2015 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# 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: 345 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
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
+DEVICE=/dev/vboxdrv
+LOG="/var/log/vbox-install.log"
+MODPROBE=/sbin/modprobe
+SCRIPTNAME=vboxdrv
+
+if $MODPROBE -c | grep -q '^allow_unsupported_modules  *0'; then
+  MODPROBE="$MODPROBE --allow-unsupported-modules"
+fi
+
+[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
+export BUILD_TYPE
+export USERNAME
+export USER=$USERNAME
+
+if [ -n "$INSTALL_DIR" ]; then
+    VIRTUALBOX="$INSTALL_DIR/VirtualBox"
+    VBOXMANAGE="$INSTALL_DIR/VBoxManage"
+    MODULE_SRC="$INSTALL_DIR/src/vboxhost"
+else
+    VIRTUALBOX="/usr/lib/virtualbox/VirtualBox"
+    VBOXMANAGE="/usr/lib/virtualbox/VBoxManage"
+    MODULE_SRC="/usr/share/virtualbox/src/vboxhost"
+fi
+BUILDINTMP="$MODULE_SRC/build_in_tmp"
+if test -u "${VIRTUALBOX}"; then
+    GROUP=root
+else
+    GROUP=vboxusers
+fi
+
+# silently exit if the package was uninstalled but not purged,
+# applies to Debian packages only (but shouldn't hurt elsewhere)
+[ ! -f /etc/debian_release -o -x $VBOXMANAGE -a -x $BUILDINTMP ] || exit 0
+
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# Preamble for Gentoo
+if [ "`which $0`" = "/sbin/rc" ]; then
+    shift
+fi
+
+begin_msg()
+{
+    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
+    logger "${SCRIPTNAME}: ${1}."
+}
+
+succ_msg()
+{
+    logger "${SCRIPTNAME}: done."
+}
+
+fail_msg()
+{
+    echo "${SCRIPTNAME}: failed: ${1}." >&2
+    logger "${SCRIPTNAME}: failed: ${1}."
+}
+
+failure()
+{
+    fail_msg "$1"
+    exit 0
+}
+
+running()
+{
+    lsmod | grep -q "$1[^_-]"
+}
+
+start()
+{
+    begin_msg "Starting VirtualBox kernel modules" console
+    if [ -d /proc/xen ]; then
+        failure "Running VirtualBox in a Xen environment is not supported"
+    fi
+    if ! running vboxdrv; then
+        if ! rm -f $DEVICE; then
+            failure "Cannot remove $DEVICE"
+        fi
+        if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
+            setup
+            if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
+                failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
+            fi
+        fi
+        sleep .2
+    fi
+    # ensure the character special exists
+    if [ ! -c $DEVICE ]; then
+        MAJOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/devices`
+        if [ ! -z "$MAJOR" ]; then
+            MINOR=0
+        else
+            MINOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/misc`
+            if [ ! -z "$MINOR" ]; then
+                MAJOR=10
+            fi
+        fi
+        if [ -z "$MAJOR" ]; then
+            rmmod vboxdrv 2>/dev/null
+            failure "Cannot locate the VirtualBox device"
+        fi
+        if ! mknod -m 0660 $DEVICE c $MAJOR $MINOR 2>/dev/null; then
+            rmmod vboxdrv 2>/dev/null
+            failure "Cannot create device $DEVICE with major $MAJOR and minor $MINOR"
+        fi
+    fi
+    # ensure permissions
+    if ! chown :"${GROUP}" $DEVICE 2>/dev/null; then
+        rmmod vboxpci 2>/dev/null
+        rmmod vboxnetadp 2>/dev/null
+        rmmod vboxnetflt 2>/dev/null
+        rmmod vboxdrv 2>/dev/null
+        failure "Cannot change group ${GROUP} for device $DEVICE"
+    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
+    if ! $MODPROBE vboxpci > /dev/null 2>&1; then
+        failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
+    fi
+    # Create the /dev/vboxusb directory if the host supports that method
+    # of USB access.  The USB code checks for the existance of that path.
+    if grep -q usb_device /proc/devices; then
+        mkdir -p -m 0750 /dev/vboxusb 2>/dev/null
+        chown root:vboxusers /dev/vboxusb 2>/dev/null
+    fi
+    succ_msg
+}
+
+stop()
+{
+    begin_msg "Stopping VirtualBox kernel modules" console
+    if running vboxpci; then
+        if ! rmmod vboxpci 2>/dev/null; then
+            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 vboxdrv; then
+        if running vboxnetflt; then
+            if ! rmmod vboxnetflt 2>/dev/null; then
+                failure "Cannot unload module vboxnetflt"
+            fi
+        fi
+        if ! rmmod vboxdrv 2>/dev/null; then
+            failure "Cannot unload module vboxdrv"
+        fi
+        if ! rm -f $DEVICE; then
+            failure "Cannot unlink $DEVICE"
+        fi
+    fi
+    succ_msg
+}
+
+# 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!
+        if [ -d /tmp/.vbox-$i-ipc ]; then
+            export VBOX_IPC_SOCKETID="$i"
+            VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
+            if [ -n "$VMS" ]; then
+                if [ "$SHUTDOWN" = "poweroff" ]; then
+                    begin_msg "Powering off remaining VMs"
+                    for v in $VMS; do
+                        $VBOXMANAGE --nologo controlvm $v poweroff
+                    done
+                    succ_msg
+                elif [ "$SHUTDOWN" = "acpibutton" ]; then
+                    begin_msg "Sending ACPI power button event to remaining VMs"
+                    for v in $VMS; do
+                        $VBOXMANAGE --nologo controlvm $v acpipowerbutton
+                        wait=30
+                    done
+                    succ_msg
+                elif [ "$SHUTDOWN" = "savestate" ]; then
+                    begin_msg "Saving state of remaining VMs"
+                    for v in $VMS; do
+                        $VBOXMANAGE --nologo controlvm $v savestate
+                    done
+                    succ_msg
+                fi
+            fi
+        fi
+    done
+    # wait for some seconds when doing ACPI shutdown
+    if [ "$wait" -ne 0 ]; then
+        begin_msg "Waiting for $wait seconds for VM shutdown"
+        sleep $wait
+        succ_msg
+    fi
+}
+
+# setup_script
+setup()
+{
+    begin_msg "Building VirtualBox kernel modules" console
+    stop >/dev/null
+    if find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|grep -q vboxpci; then
+        begin_msg "Removing old VirtualBox pci kernel module"
+        find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2>/dev/null
+        succ_msg
+    fi  
+    if find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|grep -q vboxnetadp; then
+        begin_msg "Removing old VirtualBox netadp kernel module"
+        find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2>/dev/null
+        succ_msg
+    fi  
+    if find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|grep -q vboxnetflt; then
+        begin_msg "Removing old VirtualBox netflt kernel module"
+        find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2>/dev/null
+        succ_msg
+    fi  
+    if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
+        begin_msg "Removing old VirtualBox kernel module"
+        find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2>/dev/null
+        succ_msg
+    fi
+    begin_msg "Recompiling VirtualBox kernel modules"
+    if ! $BUILDINTMP \
+        --save-module-symvers /tmp/vboxdrv-Module.symvers \
+        --module-source "$MODULE_SRC/vboxdrv" \
+        --no-print-directory install >> $LOG 2>&1; then
+        failure "Look at $LOG to find out what went wrong"
+    fi
+    if ! $BUILDINTMP \
+        --use-module-symvers /tmp/vboxdrv-Module.symvers \
+        --module-source "$MODULE_SRC/vboxnetflt" \
+        --no-print-directory install >> $LOG 2>&1; then
+        failure "Look at $LOG to find out what went wrong"
+    fi
+    if ! $BUILDINTMP \
+        --use-module-symvers /tmp/vboxdrv-Module.symvers \
+        --module-source "$MODULE_SRC/vboxnetadp" \
+        --no-print-directory install >> $LOG 2>&1; then
+        failure "Look at $LOG to find out what went wrong"
+    fi
+    if ! $BUILDINTMP \
+        --use-module-symvers /tmp/vboxdrv-Module.symvers \
+        --module-source "$MODULE_SRC/vboxpci" \
+        --no-print-directory install >> $LOG 2>&1; then
+        failure "Look at $LOG to find out what went wrong"
+    fi
+    rm -f /etc/vbox/module_not_compiled
+    succ_msg
+}
+
+dmnstatus()
+{
+    if running vboxdrv; then
+        str="vboxdrv"
+        if running vboxnetflt; then
+            str="$str, vboxnetflt"
+            if running vboxnetadp; then
+                str="$str, vboxnetadp"
+            fi
+        fi
+        if running vboxpci; then
+            str="$str, vboxpci"
+        fi
+        echo "VirtualBox kernel modules ($str) are loaded."
+        for i in $SHUTDOWN_USERS; do
+            # don't create the ipcd directory with wrong permissions!
+            if [ -d /tmp/.vbox-$i-ipc ]; then
+                export VBOX_IPC_SOCKETID="$i"
+                VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
+                if [ -n "$VMS" ]; then
+                    echo "The following VMs are currently running:"
+                    for v in $VMS; do
+                       echo "  $v"
+                    done
+                fi
+            fi
+        done
+    else
+        echo "VirtualBox kernel module is not loaded."
+    fi
+}
+
+case "$1" in
+start)
+    start
+    ;;
+stop)
+    stop_vms
+    stop
+    ;;
+stop_vms)
+    stop_vms
+    ;;
+restart)
+    stop && start
+    ;;
+force-reload)
+    stop
+    start
+    ;;
+status)
+    dmnstatus
+    ;;
+*)
+    echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status}"
+    exit 1
+esac
+
+exit 0
Index: unk/src/VBox/Installer/linux/vboxdrv.sh.in
===================================================================
--- /trunk/src/VBox/Installer/linux/vboxdrv.sh.in	(revision 58011)
+++ 	(revision )
@@ -1,347 +1,0 @@
-#! /bin/sh
-# Oracle VM VirtualBox
-# Linux kernel module init script
-
-#
-# Copyright (C) 2006-2015 Oracle Corporation
-#
-# This file is part of VirtualBox Open Source Edition (OSE), as
-# available from http://www.virtualbox.org. This file is free software;
-# you can redistribute it and/or modify it under the terms of the GNU
-# 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: 345 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
-
-## @todo get rid of the autogeneration, perhaps write "group" to
-##       a configuration file in /etc
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
-DEVICE=/dev/vboxdrv
-LOG="/var/log/vbox-install.log"
-MODPROBE=/sbin/modprobe
-SCRIPTNAME=vboxdrv
-
-if $MODPROBE -c | grep -q '^allow_unsupported_modules  *0'; then
-  MODPROBE="$MODPROBE --allow-unsupported-modules"
-fi
-
-[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
-export BUILD_TYPE
-export USERNAME
-export USER=$USERNAME
-
-if [ -n "$INSTALL_DIR" ]; then
-    VBOXMANAGE="$INSTALL_DIR/VBoxManage"
-    MODULE_SRC="$INSTALL_DIR/src/vboxhost"
-else
-    VBOXMANAGE="/usr/lib/virtualbox/VBoxManage"
-    MODULE_SRC="/usr/share/virtualbox/src/vboxhost"
-fi
-BUILDINTMP="$MODULE_SRC/build_in_tmp"
-
-# silently exit if the package was uninstalled but not purged,
-# applies to Debian packages only (but shouldn't hurt elsewhere)
-[ ! -f /etc/debian_release -o -x $VBOXMANAGE -a -x $BUILDINTMP ] || exit 0
-
-[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
-
-# Preamble for Gentoo
-if [ "`which $0`" = "/sbin/rc" ]; then
-    shift
-fi
-
-begin_msg()
-{
-    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
-    logger "${SCRIPTNAME}: ${1}."
-}
-
-succ_msg()
-{
-    logger "${SCRIPTNAME}: done."
-}
-
-fail_msg()
-{
-    echo "${SCRIPTNAME}: failed: ${1}." >&2
-    logger "${SCRIPTNAME}: failed: ${1}."
-}
-
-failure()
-{
-    fail_msg "$1"
-    exit 0
-}
-
-running()
-{
-    lsmod | grep -q "$1[^_-]"
-}
-
-start()
-{
-    begin_msg "Starting VirtualBox kernel modules" console
-    if [ -d /proc/xen ]; then
-        failure "Running VirtualBox in a Xen environment is not supported"
-    fi
-    if ! running vboxdrv; then
-        if ! rm -f $DEVICE; then
-            failure "Cannot remove $DEVICE"
-        fi
-        if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
-            setup
-            if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
-                failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
-            fi
-        fi
-        sleep .2
-    fi
-    # ensure the character special exists
-    if [ ! -c $DEVICE ]; then
-        MAJOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/devices`
-        if [ ! -z "$MAJOR" ]; then
-            MINOR=0
-        else
-            MINOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/misc`
-            if [ ! -z "$MINOR" ]; then
-                MAJOR=10
-            fi
-        fi
-        if [ -z "$MAJOR" ]; then
-            rmmod vboxdrv 2>/dev/null
-            failure "Cannot locate the VirtualBox device"
-        fi
-        if ! mknod -m 0660 $DEVICE c $MAJOR $MINOR 2>/dev/null; then
-            rmmod vboxdrv 2>/dev/null
-            failure "Cannot create device $DEVICE with major $MAJOR and minor $MINOR"
-        fi
-    fi
-    # ensure permissions
-    if ! chown :%GROUP% $DEVICE 2>/dev/null; then
-        rmmod vboxpci 2>/dev/null
-        rmmod vboxnetadp 2>/dev/null
-        rmmod vboxnetflt 2>/dev/null
-        rmmod vboxdrv 2>/dev/null
-        failure "Cannot change group %GROUP% for device $DEVICE"
-    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
-    if ! $MODPROBE vboxpci > /dev/null 2>&1; then
-        failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
-    fi
-    # Create the /dev/vboxusb directory if the host supports that method
-    # of USB access.  The USB code checks for the existance of that path.
-    if grep -q usb_device /proc/devices; then
-        mkdir -p -m 0750 /dev/vboxusb 2>/dev/null
-        chown root:vboxusers /dev/vboxusb 2>/dev/null
-    fi
-    succ_msg
-}
-
-stop()
-{
-    begin_msg "Stopping VirtualBox kernel modules" console
-    if running vboxpci; then
-        if ! rmmod vboxpci 2>/dev/null; then
-            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 vboxdrv; then
-        if running vboxnetflt; then
-            if ! rmmod vboxnetflt 2>/dev/null; then
-                failure "Cannot unload module vboxnetflt"
-            fi
-        fi
-        if ! rmmod vboxdrv 2>/dev/null; then
-            failure "Cannot unload module vboxdrv"
-        fi
-        if ! rm -f $DEVICE; then
-            failure "Cannot unlink $DEVICE"
-        fi
-    fi
-    succ_msg
-}
-
-# 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!
-        if [ -d /tmp/.vbox-$i-ipc ]; then
-            export VBOX_IPC_SOCKETID="$i"
-            VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
-            if [ -n "$VMS" ]; then
-                if [ "$SHUTDOWN" = "poweroff" ]; then
-                    begin_msg "Powering off remaining VMs"
-                    for v in $VMS; do
-                        $VBOXMANAGE --nologo controlvm $v poweroff
-                    done
-                    succ_msg
-                elif [ "$SHUTDOWN" = "acpibutton" ]; then
-                    begin_msg "Sending ACPI power button event to remaining VMs"
-                    for v in $VMS; do
-                        $VBOXMANAGE --nologo controlvm $v acpipowerbutton
-                        wait=30
-                    done
-                    succ_msg
-                elif [ "$SHUTDOWN" = "savestate" ]; then
-                    begin_msg "Saving state of remaining VMs"
-                    for v in $VMS; do
-                        $VBOXMANAGE --nologo controlvm $v savestate
-                    done
-                    succ_msg
-                fi
-            fi
-        fi
-    done
-    # wait for some seconds when doing ACPI shutdown
-    if [ "$wait" -ne 0 ]; then
-        begin_msg "Waiting for $wait seconds for VM shutdown"
-        sleep $wait
-        succ_msg
-    fi
-}
-
-# setup_script
-setup()
-{
-    begin_msg "Building VirtualBox kernel modules" console
-    stop >/dev/null
-    if find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|grep -q vboxpci; then
-        begin_msg "Removing old VirtualBox pci kernel module"
-        find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|grep -q vboxnetadp; then
-        begin_msg "Removing old VirtualBox netadp kernel module"
-        find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|grep -q vboxnetflt; then
-        begin_msg "Removing old VirtualBox netflt kernel module"
-        find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
-        begin_msg "Removing old VirtualBox kernel module"
-        find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi
-    begin_msg "Recompiling VirtualBox kernel modules"
-    if ! $BUILDINTMP \
-        --save-module-symvers /tmp/vboxdrv-Module.symvers \
-        --module-source "$MODULE_SRC/vboxdrv" \
-        --no-print-directory install >> $LOG 2>&1; then
-        failure "Look at $LOG to find out what went wrong"
-    fi
-    if ! $BUILDINTMP \
-        --use-module-symvers /tmp/vboxdrv-Module.symvers \
-        --module-source "$MODULE_SRC/vboxnetflt" \
-        --no-print-directory install >> $LOG 2>&1; then
-        failure "Look at $LOG to find out what went wrong"
-    fi
-    if ! $BUILDINTMP \
-        --use-module-symvers /tmp/vboxdrv-Module.symvers \
-        --module-source "$MODULE_SRC/vboxnetadp" \
-        --no-print-directory install >> $LOG 2>&1; then
-        failure "Look at $LOG to find out what went wrong"
-    fi
-    if ! $BUILDINTMP \
-        --use-module-symvers /tmp/vboxdrv-Module.symvers \
-        --module-source "$MODULE_SRC/vboxpci" \
-        --no-print-directory install >> $LOG 2>&1; then
-        failure "Look at $LOG to find out what went wrong"
-    fi
-    rm -f /etc/vbox/module_not_compiled
-    succ_msg
-}
-
-dmnstatus()
-{
-    if running vboxdrv; then
-        str="vboxdrv"
-        if running vboxnetflt; then
-            str="$str, vboxnetflt"
-            if running vboxnetadp; then
-                str="$str, vboxnetadp"
-            fi
-        fi
-        if running vboxpci; then
-            str="$str, vboxpci"
-        fi
-        echo "VirtualBox kernel modules ($str) are loaded."
-        for i in $SHUTDOWN_USERS; do
-            # don't create the ipcd directory with wrong permissions!
-            if [ -d /tmp/.vbox-$i-ipc ]; then
-                export VBOX_IPC_SOCKETID="$i"
-                VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
-                if [ -n "$VMS" ]; then
-                    echo "The following VMs are currently running:"
-                    for v in $VMS; do
-                       echo "  $v"
-                    done
-                fi
-            fi
-        done
-    else
-        echo "VirtualBox kernel module is not loaded."
-    fi
-}
-
-case "$1" in
-start)
-    start
-    ;;
-stop)
-    stop_vms
-    stop
-    ;;
-stop_vms)
-    stop_vms
-    ;;
-restart)
-    stop && start
-    ;;
-force-reload)
-    stop
-    start
-    ;;
-status)
-    dmnstatus
-    ;;
-*)
-    echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status}"
-    exit 1
-esac
-
-exit 0
