vboxdrv.sh revision 332d68e9666b04a5aa788a586d9f4c6b1f19c700
# Sun VirtualBox
# VirtualBox kernel module control script, Solaris hosts.
#
# Copyright (C) 2007-2009 Sun Microsystems, Inc.
#
# 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.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
CHECKARCH=""
SILENTUNLOAD=""
ALWAYSREMDRV=""
MODNAME="vboxdrv"
VBIMODNAME="vbi"
FLTMODNAME="vboxflt"
NETMODNAME="vboxnet"
USBMODNAME="vboxusbmon"
abort()
{
echo 1>&2 "## $1"
exit 1
}
info()
{
echo 1>&2 "$1"
}
warn()
{
echo 1>&2 "WARNING!! $1"
}
{
fi
return 0
fi
# Check arch only while installing (because rem_drv works for both arch.)
# amd64 ISA, x86 kernel module??
abort "Found 32-bit module instead of 64-bit. Please install the amd64 package!"
fi
else
# x86 ISA, amd64 kernel module??
abort "Found 64-bit module instead of 32-bit. Please install the x86 package!"
fi
fi
abort "VirtualBox Host kernel module NOT installed."
else
info "## VirtualBox Host kernel module NOT installed."
return 0
fi
}
{
loadentry=`cat /etc/name_to_major | grep $1`
return 1
fi
return 0
}
{
# modinfo should now work properly since we prevent module autounloading
return 1
fi
return 0
}
{
return $?
}
{
return $?
}
{
return $?
}
{
return $?
}
{
return $?
}
{
return $?
}
{
return $?
}
{
return $?
}
{
abort "Failed to find a suitable user id binary! Aborting"
else
fi
fi
abort "This program must be run with administrator privileges. Aborting"
fi
}
{
if vboxdrv_loaded; then
info "VirtualBox Host kernel module already loaded."
else
if test -n "_HARDENED_"; then
/usr/sbin/add_drv -m'* 0600 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
else
/usr/sbin/add_drv -m'* 0666 root sys' $MODNAME || abort "Failed to add VirtualBox Host Kernel module."
fi
if test ! vboxdrv_loaded; then
abort "Failed to load VirtualBox Host kernel module."
info "VirtualBox Host kernel module loaded."
else
abort "Aborting due to attach failure."
fi
fi
}
{
if vboxdrv_loaded; then
# While uninstalling we always remove the driver whether we unloaded successfully or not,
# while installing we make SURE if there is an existing driver about, it is cleanly unloaded
# and the new one is added hence the "alwaysremdrv" option.
else
/usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
else
abort "Failed to unload VirtualBox Host kernel module. Old one still active!!"
fi
fi
info "VirtualBox Host kernel module unloaded."
fi
elif vboxdrv_added; then
/usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
info "VirtualBox Host kernel module unloaded."
info "VirtualBox Host kernel module not loaded."
fi
# check for vbi and force unload it
/usr/sbin/modunload -i $vbi_mod_id
fi
}
{
if vboxflt_loaded; then
info "VirtualBox NetFilter kernel module already loaded."
else
/usr/sbin/add_drv -m'* 0600 root sys' $FLTMODNAME || abort "Failed to add VirtualBox NetFilter Kernel module."
/usr/sbin/modload -p drv/$FLTMODNAME
if test ! vboxflt_loaded; then
abort "Failed to load VirtualBox NetFilter kernel module."
else
info "VirtualBox NetFilter kernel module loaded."
fi
fi
}
{
if vboxflt_loaded; then
# see stop_vboxdrv() for why we have "alwaysremdrv".
else
/usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
else
abort "Failed to unload VirtualBox NetFilter kernel module. Old one still active!!"
fi
fi
info "VirtualBox NetFilter kernel module unloaded."
fi
elif vboxflt_added; then
/usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
info "VirtualBox NetFilter kernel module unloaded."
info "VirtualBox NetFilter kernel module not loaded."
fi
}
{
if vboxnet_loaded; then
info "VirtualBox NetAdapter kernel module already loaded."
else
/usr/sbin/add_drv -m'* 0666 root sys' $NETMODNAME || abort "Failed to add VirtualBox NetAdapter Kernel module."
/usr/sbin/modload -p drv/$NETMODNAME
if test ! vboxnet_loaded; then
abort "Failed to load VirtualBox NetAdapter kernel module."
else
# Plumb the interface!
info "VirtualBox NetAdapter kernel module loaded."
fi
fi
}
{
if vboxnet_loaded; then
# see stop_vboxdrv() for why we have "alwaysremdrv".
else
/usr/sbin/rem_drv $NETMODNAME || abort "Unloaded VirtualBox NetAdapter kernel module, but failed to remove it!"
else
abort "Failed to unload VirtualBox NetAdapter kernel module. Old one still active!!"
fi
fi
info "VirtualBox NetAdapter kernel module unloaded."
fi
elif vboxnet_added; then
/usr/sbin/rem_drv $NETMODNAME || abort "Unloaded VirtualBox NetAdapter kernel module, but failed to remove it!"
info "VirtualBox NetAdapter kernel module unloaded."
info "VirtualBox NetAdapter kernel module not loaded."
fi
}
{
if vboxusbmon_loaded; then
info "VirtualBox USB Monitor kernel module already loaded."
else
/usr/sbin/add_drv -m'* 0666 root sys' $USBMODNAME || abort "Failed to add VirtualBox USB Monitor Kernel module."
/usr/sbin/modload -p drv/$USBMODNAME
if test ! vboxusbmon_loaded; then
abort "Failed to load VirtualBox USB kernel module."
else
info "VirtualBox USB kernel module loaded."
fi
fi
}
{
if vboxusbmon_loaded; then
# see stop_vboxdrv() for why we have "alwaysremdrv".
else
/usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB Monitor kernel module, but failed to remove it!"
else
abort "Failed to unload VirtualBox USB Monitor kernel module. Old one still active!!"
fi
fi
info "VirtualBox USB kernel module unloaded."
fi
elif vboxusbmon_added; then
/usr/sbin/rem_drv $USBMODNAME || abort "Unloaded VirtualBox USB Monitor kernel module, but failed to remove it!"
info "VirtualBox USB kernel module unloaded."
info "VirtualBox USB kernel module not loaded."
fi
}
{
if vboxdrv_loaded; then
info "Running."
elif vboxdrv_added; then
info "Inactive."
else
info "Not installed."
fi
}
{
}
{
}
if test "$2" = "silentunload" || test "$3" = "silentunload"; then
SILENTUNLOAD="$2"
fi
if test "$2" = "alwaysremdrv" || test "$3" = "alwaysremdrv"; then
ALWAYSREMDRV="alwaysremdrv"
fi
if test "$2" = "checkarch" || test "$3" = "checkarch"; then
CHECKARCH="checkarch"
fi
case "$1" in
;;
;;
;;
stop)
;;
;;
;;
;;
;;
;;
;;
;;
*)
echo "Usage: $0 {start|stop|status|fltstart|fltstop|usbstart|usbstop|netstart|netstop|stopall|startall}"
exit 1
esac
exit 0