3 # virtualbox VirtualBox virtualizer for x86 hardware
5 # description: Oracle VirtualBox is a general-purpose full virtualizer for x86 \
6 # hardware. Targeted at server, desktop and embedded use.
8 # Source function library
9 . /etc/rc.d/init.d/functions
11 VBOX_DEVICE="/dev/vboxnetctl"
12 VBOX_MODULE="vboxnetadp"
14 # Get service config - may override defaults
15 [ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
18 modprobe -s $VBOX_MODULE
21 if [ -d /dev/.udev ] || [ -d /run/udev/rules.d ]; then
25 # set proper $VBOX_DEVICE for systems with static dev
26 show "Setting $VBOX_DEVICE entry"; busy
28 VBOX_MAJOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/devices)
29 if [ -n "$VBOX_MAJOR" ]; then
32 VBOX_MINOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/misc)
33 if [ -n "$VBOX_MINOR" ]; then
34 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
38 if [ -z "$VBOX_MAJOR" ]; then
39 /sbin/rmmod $VBOX_MODULE
41 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
45 elif ! chown root:vbox $VBOX_DEVICE; then
55 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
60 touch /var/lock/subsys/$VBOX_MODULE
64 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
65 /sbin/rmmod $VBOX_MODULE
66 rm -f /var/lock/subsys/$VBOX_MODULE
70 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
79 # See how we were called.
101 if ! is_module $VBOX_MODULE; then
102 echo "$VBOX_MODULE module is loaded"
104 echo "$VBOX_MODULE module is not loaded"
107 if [ ! -c $VBOX_DEVICE ]; then
108 echo "$VBOX_DEVICE does not exist"
111 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
115 msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}"