3 # virtualbox VirtualBox virtualizer for x86 hardware
7 # description: InnoTek VirtualBox is a general-purpose full virtualizer for x86
8 # hardware. Targeted at server, desktop and embedded use.
12 # Source function library
13 . /etc/rc.d/init.d/functions
15 VBOX_DEVICE="/dev/vboxnetctl"
16 VBOX_MODULE="vboxnetadp"
18 # Get service config - may override defaults
19 [ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
22 modprobe -s $VBOX_MODULE
24 if [ -d /dev/.udev ]; then
28 # set proper $VBOX_DEVICE for systems with static dev
29 show "Setting $VBOX_DEVICE entry"; busy
31 VBOX_MAJOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/devices)
32 if [ -n "$VBOX_MAJOR" ]; then
35 VBOX_MINOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/misc)
36 if [ -n "$VBOX_MINOR" ]; then
37 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
41 if [ -z "$VBOX_MAJOR" ]; then
42 /sbin/rmmod $VBOX_MODULE
44 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
48 elif ! chown root:vbox $VBOX_DEVICE; then
58 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
63 touch /var/lock/subsys/$VBOX_MODULE
67 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
68 /sbin/rmmod $VBOX_MODULE
69 rm -f /var/lock/subsys/$VBOX_MODULE
73 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
82 # See how we were called.
104 if ! is_module $VBOX_MODULE; then
105 echo "$VBOX_MODULE module is loaded"
107 echo "$VBOX_MODULE module is not loaded"
110 if [ ! -c $VBOX_DEVICE ]; then
111 echo "$VBOX_DEVICE does not exist"
114 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
118 msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}"