]> git.pld-linux.org Git - packages/VirtualBox.git/blame - VirtualBox-vboxguest.init
- udev>166 use /run/udev, check that too
[packages/VirtualBox.git] / VirtualBox-vboxguest.init
CommitLineData
42be133e
AG
1#!/bin/sh
2#
3# virtualbox VirtualBox virtualizer for x86 hardware
4#
5# chkconfig: 345 83 26
6#
7# description: InnoTek VirtualBox is a general-purpose full virtualizer for x86
8# hardware. Targeted at server, desktop and embedded use.
9#
10# $Id$
11
12# Source function library
13. /etc/rc.d/init.d/functions
14
15VBOX_DEVICE="/dev/vboxguest"
16VBOX_MODULE="vboxguest"
17
18# Get service config - may override defaults
19[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
20
f8d383ed
ER
21setup() {
22 modprobe -s $VBOX_MODULE
6e05a0a4 23 RETVAL=$?
2fdccbd8 24 if [ -d /dev/.udev ]; then
6e05a0a4 25 return $RETVAL
2fdccbd8
ER
26 fi
27
28 # set proper $VBOX_DEVICE for systems with static dev
29 show "Setting $VBOX_DEVICE entry"; busy
30 rm -f $VBOX_DEVICE
31 VBOX_MAJOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/devices)
32 if [ -n "$VBOX_MAJOR" ]; then
33 VBOX_MINOR=0
34 else
35 VBOX_MINOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/misc)
36 if [ -n "$VBOX_MINOR" ]; then
37 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
f8d383ed
ER
38 fi
39 fi
6e05a0a4 40
2fdccbd8
ER
41 if [ -z "$VBOX_MAJOR" ]; then
42 /sbin/rmmod $VBOX_MODULE
6e05a0a4 43 RETVAL=1
2fdccbd8 44 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
6e05a0a4 45 RETVAL=$?
2fdccbd8
ER
46 rmmod $VBOX_MODNAME
47 fail
48 elif ! chown root:vbox $VBOX_DEVICE; then
6e05a0a4 49 RETVAL=$?
2fdccbd8
ER
50 fail
51 else
52 ok
53 fi
6e05a0a4 54 return $RETVAL
f8d383ed
ER
55}
56
57start() {
58 if [ -f /var/lock/subsys/vboxguest ]; then
59 return
42be133e 60 fi
6e05a0a4 61 setup || exit $?
f8d383ed 62 touch /var/lock/subsys/vboxguest
42be133e
AG
63}
64
65stop() {
66 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
67 /sbin/rmmod $VBOX_MODULE
68 rm -f /var/lock/subsys/vboxguest
69}
70
71RETVAL=0
72# See how we were called.
73case "$1" in
74 start)
75 start
76 ;;
77 stop)
78 stop
79 ;;
80 restart)
81 stop
82 start
83 ;;
f8d383ed
ER
84 setup)
85 setup
86 ;;
42be133e
AG
87 status)
88 if ! is_module $VBOX_MODULE; then
89 echo "$VBOX_MODULE module is loaded"
90 else
91 echo "$VBOX_MODULE module is not loaded"
92 RETVAL=3
93 fi
94 if [ ! -c $VBOX_DEVICE ]; then
95 echo "$VBOX_DEVICE does not exist"
96 RETVAL=3
97 else
98 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
99 fi
100 ;;
101 *)
f8d383ed 102 msg_usage "$0 {start|stop|restart|setup|status}"
42be133e
AG
103 exit 3
104esac
105
106exit $RETVAL
This page took 0.048036 seconds and 4 git commands to generate.