vboxdrv.sh revision 8b25c8408b05954c4f6401a8e9bbacf76daa7a69
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Sun xVM VirtualBox
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# VirtualBox kernel module control script, Solaris hosts.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# Copyright (C) 2007-2008 Sun Microsystems, Inc.
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# 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 # Check arch only while installing (because rem_drv works for both arch.)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # Let us go a step further and check if user has mixed up x86/amd64
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Found 32-bit module instead of 64-bit. Please install the amd64 package!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Found 64-bit module instead of 32-bit. Please install the x86 package!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "VirtualBox Host kernel module NOT installed."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "## VirtualBox Host kernel module NOT installed."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # modinfo should now work properly since we prevent module autounloading
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to find a suitable user id binary! Aborting"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "This program must be run with administrator privileges. Aborting"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox Host kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0666 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
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 vboxdrv_mod_id=`/usr/sbin/modinfo | grep $MODNAME | cut -f 1 -d ' ' `
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 /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox Host kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vbi_mod_id=`/usr/sbin/modinfo | grep $VBIMODNAME | cut -f 1 -d ' ' `
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $FLTMODNAME || abort "Failed to add VirtualBox NetFilter Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! vboxflt_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to load VirtualBox NetFilter kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vboxflt_mod_id=`/usr/sbin/modinfo | grep $FLTMODNAME | cut -f 1 -d ' '`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # see stop_vboxdrv() for why we have "alwaysremdrv".
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox NetFilter kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox NetFilter kernel module unloaded."
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 info "VirtualBox NetFilter kernel module not loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync info "VirtualBox USB kernel module already loaded."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/add_drv -m'* 0600 root sys' $USBMODNAME || abort "Failed to add VirtualBox USB Kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if test ! vboxusb_loaded; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to load VirtualBox USB kernel module."
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vboxusb_mod_id=`/usr/sbin/modinfo | grep $USBMODNAME | cut -f 1 -d ' '`
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync # see stop_vboxdrv() for why we have "alwaysremdrv".
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync abort "Failed to unload VirtualBox USB kernel module. Old one still active!!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync /usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB kernel module, but failed to remove it!"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "silentunload" || test "$3" = "silentunload"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "alwaysremdrv" || test "$3" = "alwaysremdrv"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncif test "$2" = "checkarch" || test "$3" = "checkarch"; then
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync echo "Usage: $0 {start|stop|status|fltstart|fltstop|usbstart|usbstop|stopall|startall}"