vboxdrv.sh revision 546cd3313d635980a2cc168a79a58b4f0858d784
# Sun xVM VirtualBox
# VirtualBox kernel module control script, Solaris hosts.
#
# Copyright (C) 2007-2008 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"
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 $?
}
{
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 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|stopall|startall}"
exit 1
esac
exit 0