]> git.pld-linux.org Git - packages/VirtualBox.git/commitdiff
- also create the device
authorElan Ruusamäe <glen@pld-linux.org>
Sat, 24 Mar 2012 12:46:39 +0000 (12:46 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    VirtualBox-vboxnetadp.init -> 1.3

VirtualBox-vboxnetadp.init

index b3c050a0b68e11c343df8ceee5496a16abd15832..2d5283c8a99c1dd2ef48b379ada08466ab052b13 100644 (file)
@@ -18,23 +18,59 @@ VBOX_MODULE="vboxnetadp"
 # Get service config - may override defaults
 [ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
 
+setup() {
+       modprobe -s $VBOX_MODULE
+       RETVAL=$?
+       if [ -d /dev/.udev ]; then
+               return $RETVAL
+       fi
+
+       # set proper $VBOX_DEVICE for systems with static dev
+       show "Setting $VBOX_DEVICE entry"; busy
+       rm -f $VBOX_DEVICE
+       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 -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
+               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/vboxnetadp ]; then
+       if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
                return
        fi
 
-       modprobe -s $VBOX_MODULE
-       touch /var/lock/subsys/vboxnetadp
+       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/vboxnetadp
+       rm -f /var/lock/subsys/$VBOX_MODULE
 }
 
 condrestart() {
-       if [ -f /var/lock/subsys/vboxnetadp ]; then
+       if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
                stop
                start
        else
@@ -61,6 +97,9 @@ case "$1" in
   force-reload)
        condrestart 7
        ;;
+  setup)
+       setup
+       ;;
   status)
        if ! is_module $VBOX_MODULE; then
                echo "$VBOX_MODULE module is loaded"
@@ -68,9 +107,15 @@ case "$1" in
                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
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}"
        exit 3
 esac
 
This page took 0.066263 seconds and 4 git commands to generate.