]> git.pld-linux.org Git - packages/VirtualBox.git/blobdiff - VirtualBox-vboxdrv.init
- rel 3
[packages/VirtualBox.git] / VirtualBox-vboxdrv.init
index 2461c77397b17aabe4a53e3779c5b347592e2ade..4d39d61fc6a6117d462f1274c83990e23e120549 100644 (file)
@@ -2,7 +2,7 @@
 #
 # virtualbox   VirtualBox virtualizer for x86 hardware
 #
-# chkconfig:   345 84 25
+# chkconfig:   345 82 27
 #
 # description: InnoTek VirtualBox is a general-purpose full virtualizer for x86 
 #              hardware. Targeted at server, desktop and embedded use.
 # Source function library
 . /etc/rc.d/init.d/functions
 
-# Get service config - may override defaults
-[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
-
 VBOX_DEVICE="/dev/vboxdrv"
 VBOX_MODULE="vboxdrv"
 
-start() {
+# Get service config - may override defaults
+[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
+
+setup() {
        modprobe -s $VBOX_MODULE
+       if [ -d /dev/.udev ]; then
+               return
+       fi
+
        # set proper /dev/vboxdrv for systems with static dev
-       if ! [ -d /dev/.udev/ ]; then
-               show "Setting $VBOX_DEVICE entry"
-               busy
-               rm -f $VBOX_DEVICE
-               VBOX_MAJOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/devices)
-               if [ -n "$VBOX_MAJOR" ]; then
-                       VBOX_MINOR=0
-               else
-                       VBOX_MINOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/misc)
-                       if [ -n "$VBOX_MINOR" ]; then
-                               VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
-                       fi
-               fi
-               if [ -z "$VBOX_MAJOR" ]; then
-                       /sbin/rmmod $VBOX_MODULE
-                       fail
-               elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
-                       rmmod $VBOX_MODNAME
-                       fail
-               elif ! chown root:vbox $VBOX_DEVICE; then
-                       fail
-               else
-                       ok
+       show "Setting $VBOX_DEVICE entry"; busy
+       rm -f $VBOX_DEVICE
+       VBOX_MAJOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/devices)
+       if [ -n "$VBOX_MAJOR" ]; then
+               VBOX_MINOR=0
+       else
+               VBOX_MINOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/misc)
+               if [ -n "$VBOX_MINOR" ]; then
+                       VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
                fi
        fi
+       if [ -z "$VBOX_MAJOR" ]; then
+               /sbin/rmmod $VBOX_MODULE
+               fail
+       elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
+               rmmod $VBOX_MODNAME
+               fail
+       elif ! chown root:vbox $VBOX_DEVICE; then
+               fail
+       else
+               ok
+       fi
+}
+
+start() {
+       if [ -f /var/lock/subsys/vboxdrv ]; then
+               return
+       fi
+
+       setup
+       touch /var/lock/subsys/vboxdrv
 }
 
 stop() {
-       # NOTE: rmmod will wait if device is in use, so automatic rmmod probably not the best idea
+       # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
        /sbin/rmmod $VBOX_MODULE
+       rm -f /var/lock/subsys/vboxdrv
 }
 
 RETVAL=0
@@ -66,21 +77,25 @@ case "$1" in
        stop
        start
        ;;
+  setup)
+       setup
+       ;;
   status)
        if ! is_module $VBOX_MODULE; then
                echo "$VBOX_MODULE module is loaded"
        else
                echo "$VBOX_MODULE module is not loaded"
+               RETVAL=3
        fi
        if [ ! -c $VBOX_DEVICE ]; then
                echo "$VBOX_DEVICE does not exist"
+               RETVAL=3
        else
                echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
        fi
-       RETVAL=$?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|status}"
+       msg_usage "$0 {start|stop|restart|setup|status}"
        exit 3
 esac
 
This page took 0.074223 seconds and 4 git commands to generate.