3 # virtualbox VirtualBox virtualizer for x86 hardware
7 # description: Oracle 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_MODULE="vboxguest"
16 VBOX_GUEST_DEVICE="/dev/vboxguest"
17 VBOX_USER_DEVICE="/dev/vboxuser"
19 # Get service config - may override defaults
20 [ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
23 local VBOX_MODULE=$1 VBOX_DEVICE=$2
24 modprobe -s $VBOX_MODULE
27 if [ -d /dev/.udev ] || [ -d /run/udev/rules.d ]; then
31 # set proper $VBOX_DEVICE for systems with static dev
32 show "Setting $VBOX_DEVICE entry"; busy
34 VBOX_MAJOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/devices)
35 if [ -n "$VBOX_MAJOR" ]; then
38 VBOX_MINOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/misc)
39 if [ -n "$VBOX_MINOR" ]; then
40 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
44 if [ -z "$VBOX_MAJOR" ]; then
45 /sbin/rmmod $VBOX_MODULE
47 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
51 elif ! chown root:vbox $VBOX_DEVICE; then
61 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
65 setup $VBOX_MODULE $VBOX_GUEST_DEVICE || exit $?
66 setup $VBOX_MODULE $VBOX_USER_DEVICE || exit $?
67 touch /var/lock/subsys/$VBOX_MODULE
71 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
72 /sbin/rmmod $VBOX_MODULE
73 rm -f /var/lock/subsys/$VBOX_MODULE
77 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
86 # See how we were called.
108 if ! is_module $VBOX_MODULE; then
109 echo "$VBOX_MODULE module is loaded"
111 echo "$VBOX_MODULE module is not loaded"
114 if [ ! -c $VBOX_DEVICE ]; then
115 echo "$VBOX_DEVICE does not exist"
118 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
122 msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}"