vboxdrv.sh revision 8b25c8408b05954c4f6401a8e9bbacf76daa7a69
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#!/bin/sh
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Sun xVM VirtualBox
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# VirtualBox kernel module control script, Solaris hosts.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Copyright (C) 2007-2008 Sun Microsystems, Inc.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# available from http://www.virtualbox.org. This file is free software;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# you can redistribute it and/or modify it under the terms of the GNU
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# General Public License (GPL) as published by the Free Software
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# additional information or have any questions.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncCHECKARCH=""
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncSILENTUNLOAD=""
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncALWAYSREMDRV=""
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncMODNAME="vboxdrv"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncVBIMODNAME="vbi"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncFLTMODNAME="vboxflt"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncUSBMODNAME="vboxusb"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncMODDIR32="/platform/i86pc/kernel/drv"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncMODDIR64=$MODDIR32/amd64
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncabort()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync echo 1>&2 "## $1"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync exit 1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncinfo()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync echo 1>&2 "$1"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncwarn()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync echo 1>&2 "WARNING!! $1"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynccheck_if_installed()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync cputype=`isainfo -k`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync modulepath="$MODDIR32/$MODNAME"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test "$cputype" = "amd64"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync modulepath="$MODDIR64/$MODNAME"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -f "$modulepath"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
e6893ed982eda980cc85d16b13ded4ed6e6dd351vboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # Check arch only while installing (because rem_drv works for both arch.)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! -z "$CHECKARCH"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # Let us go a step further and check if user has mixed up x86/amd64
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # amd64 ISA, x86 kernel module??
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test "$cputype" = "amd64"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync modulepath="$MODDIR32/$MODNAME"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -f "$modulepath"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Found 32-bit module instead of 64-bit. Please install the amd64 package!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # x86 ISA, amd64 kernel module??
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync modulepath="$MODDIR64/$MODNAME"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -f "$modulepath"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Found 64-bit module instead of 32-bit. Please install the x86 package!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "VirtualBox Host kernel module NOT installed."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "## VirtualBox Host kernel module NOT installed."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncmodule_added()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync loadentry=`cat /etc/name_to_major | grep $1`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -z "$loadentry"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncmodule_loaded()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # modinfo should now work properly since we prevent module autounloading
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync loadentry=`/usr/sbin/modinfo | grep $1`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -z "$loadentry"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxdrv_loaded()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_loaded $MODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxdrv_added()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_added $MODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxflt_loaded()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_loaded $FLTMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxflt_added()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_added $FLTMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxusb_added()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_added $USBMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvboxusb_loaded()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync module_loaded $USBMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return $?
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynccheck_root()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync idbin=/usr/xpg4/bin/id
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! -f "$idbin"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync found=`which id | grep "no id"`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! -z "$found"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to find a suitable user id binary! Aborting"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync idbin=$found
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test `$idbin -u` -ne 0; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "This program must be run with administrator privileges. Aborting"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstart_module()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxdrv_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "_HARDENED_"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0666 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modload -p drv/$MODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! vboxdrv_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to load VirtualBox Host kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif test -c "/devices/pseudo/$MODNAME@0:$MODNAME"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Aborting due to attach failure."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstop_module()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxdrv_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vboxdrv_mod_id=`/usr/sbin/modinfo | grep $MODNAME | cut -f 1 -d ' ' `
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$vboxdrv_mod_id"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modunload -i $vboxdrv_mod_id
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # While uninstalling we always remove the driver whether we unloaded successfully or not,
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # while installing we make SURE if there is an existing driver about, it is cleanly unloaded
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # and the new one is added hence the "alwaysremdrv" option.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$ALWAYSREMDRV"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $MODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test "$?" -eq 0; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox Host kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif vboxdrv_added; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif test -z "$SILENTUNLOAD"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module not loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # check for vbi and force unload it
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vbi_mod_id=`/usr/sbin/modinfo | grep $VBIMODNAME | cut -f 1 -d ' ' `
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$vbi_mod_id"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modunload -i $vbi_mod_id
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstart_vboxflt()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxflt_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $FLTMODNAME || abort "Failed to add VirtualBox NetFilter Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modload -p drv/$FLTMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! vboxflt_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to load VirtualBox NetFilter kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstop_vboxflt()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxflt_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vboxflt_mod_id=`/usr/sbin/modinfo | grep $FLTMODNAME | cut -f 1 -d ' '`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$vboxflt_mod_id"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modunload -i $vboxflt_mod_id
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # see stop_vboxdrv() for why we have "alwaysremdrv".
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$ALWAYSREMDRV"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $FLTMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test "$?" -eq 0; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox NetFilter kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif vboxflt_added; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif test -z "$SILENTUNLOAD"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module not loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstart_vboxusb()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxusb_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $USBMODNAME || abort "Failed to add VirtualBox USB Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modload -p drv/$USBMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! vboxusb_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to load VirtualBox USB kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstop_vboxusb()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxusb_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vboxusb_mod_id=`/usr/sbin/modinfo | grep $USBMODNAME | cut -f 1 -d ' '`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$vboxusb_mod_id"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/modunload -i $vboxusb_mod_id
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # see stop_vboxdrv() for why we have "alwaysremdrv".
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test -n "$ALWAYSREMDRV"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $USBMODNAME
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test "$?" -eq 0; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox USB kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif vboxusb_added; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module unloaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif test -z "$SILENTUNLOAD"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module not loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatus_vboxdrv()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if vboxdrv_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "Running."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync elif vboxdrv_added; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "Inactive."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "Not installed."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstop_all_modules()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_vboxusb
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_vboxflt
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_module
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstart_all_modules()
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_module
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_vboxflt
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_vboxusb
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynccheck_root
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynccheck_if_installed
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "silentunload" || test "$3" = "silentunload"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync SILENTUNLOAD="$2"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncfi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "alwaysremdrv" || test "$3" = "alwaysremdrv"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ALWAYSREMDRV="alwaysremdrv"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncfi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "checkarch" || test "$3" = "checkarch"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync CHECKARCH="checkarch"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncfi
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynccase "$1" in
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstopall)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_all_modules
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstartall)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_all_modules
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstart)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_module
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstop)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_module
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatus)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync status_vboxdrv
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncfltstart)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_vboxflt
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncfltstop)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_vboxflt
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncusbstart)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync start_vboxusb
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncusbstop)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync stop_vboxusb
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ;;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync*)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync echo "Usage: $0 {start|stop|status|fltstart|fltstop|usbstart|usbstop|stopall|startall}"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync exit 1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncesac
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncexit 0
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync