X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=VirtualBox-vboxdrv.init;h=2df64fe782cfa3b7662969e2b93d8b45004b6cda;hb=b379017dd54ce79a9578c32f22f937f0ac4077a5;hp=4d39d61fc6a6117d462f1274c83990e23e120549;hpb=f8d383ed7f00d93bb170120d934e60b4fb9011f8;p=packages%2FVirtualBox.git diff --git a/VirtualBox-vboxdrv.init b/VirtualBox-vboxdrv.init index 4d39d61..2df64fe 100644 --- a/VirtualBox-vboxdrv.init +++ b/VirtualBox-vboxdrv.init @@ -4,7 +4,7 @@ # # chkconfig: 345 82 27 # -# description: InnoTek VirtualBox is a general-purpose full virtualizer for x86 +# description: Oracle VirtualBox is a general-purpose full virtualizer for x86 \ # hardware. Targeted at server, desktop and embedded use. # # $Id$ @@ -20,48 +20,63 @@ VBOX_MODULE="vboxdrv" setup() { modprobe -s $VBOX_MODULE - if [ -d /dev/.udev ]; then - return + RETVAL=$? + + if [ -d /dev/.udev ] || [ -d /run/udev/rules.d ]; then + return $RETVAL fi - # set proper /dev/vboxdrv for systems with static dev + # set proper $VBOX_DEVICE for systems with static dev show "Setting $VBOX_DEVICE entry"; busy rm -f $VBOX_DEVICE - VBOX_MAJOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/devices) + VBOX_MAJOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/devices) if [ -n "$VBOX_MAJOR" ]; then VBOX_MINOR=0 else - VBOX_MINOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/misc) + VBOX_MINOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {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 + RETVAL=1 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then + RETVAL=$? rmmod $VBOX_MODNAME fail elif ! chown root:vbox $VBOX_DEVICE; then + RETVAL=$? fail else ok fi + return $RETVAL } start() { - if [ -f /var/lock/subsys/vboxdrv ]; then + if [ -f /var/lock/subsys/$VBOX_MODULE ]; then return fi - setup - touch /var/lock/subsys/vboxdrv + setup || exit $? + touch /var/lock/subsys/$VBOX_MODULE } stop() { # 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 + rm -f /var/lock/subsys/$VBOX_MODULE +} + +condrestart() { + if [ -f /var/lock/subsys/$VBOX_MODULE ]; then + stop + start + else + RETVAL=$1 + fi } RETVAL=0 @@ -77,6 +92,12 @@ case "$1" in stop start ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; setup) setup ;; @@ -95,7 +116,7 @@ case "$1" in fi ;; *) - msg_usage "$0 {start|stop|restart|setup|status}" + msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}" exit 3 esac