]> git.pld-linux.org Git - packages/VirtualBox.git/blame - VirtualBox-vboxguest.init
- release 8
[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
23 # set proper /dev/vboxdrv for systems with static dev
24 if [ ! -d /dev/.udev ]; then
25 show "Setting $VBOX_DEVICE entry"
26 busy
27 rm -f $VBOX_DEVICE
28 VBOX_MAJOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/devices)
29 if [ -n "$VBOX_MAJOR" ]; then
30 VBOX_MINOR=0
31 else
32 VBOX_MINOR=$(awk '$2 == "vboxdrv" {print $1}' /proc/misc)
33 if [ -n "$VBOX_MINOR" ]; then
34 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
42be133e
AG
35 fi
36 fi
f8d383ed
ER
37 if [ -z "$VBOX_MAJOR" ]; then
38 /sbin/rmmod $VBOX_MODULE
39 fail
40 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
41 rmmod $VBOX_MODNAME
42 fail
43 elif ! chown root:vbox $VBOX_DEVICE; then
44 fail
45 else
46 ok
47 fi
48 fi
49}
50
51start() {
52 if [ -f /var/lock/subsys/vboxguest ]; then
53 return
42be133e 54 fi
f8d383ed
ER
55 setup
56 touch /var/lock/subsys/vboxguest
42be133e
AG
57}
58
59stop() {
60 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
61 /sbin/rmmod $VBOX_MODULE
62 rm -f /var/lock/subsys/vboxguest
63}
64
65RETVAL=0
66# See how we were called.
67case "$1" in
68 start)
69 start
70 ;;
71 stop)
72 stop
73 ;;
74 restart)
75 stop
76 start
77 ;;
f8d383ed
ER
78 setup)
79 setup
80 ;;
42be133e
AG
81 status)
82 if ! is_module $VBOX_MODULE; then
83 echo "$VBOX_MODULE module is loaded"
84 else
85 echo "$VBOX_MODULE module is not loaded"
86 RETVAL=3
87 fi
88 if [ ! -c $VBOX_DEVICE ]; then
89 echo "$VBOX_DEVICE does not exist"
90 RETVAL=3
91 else
92 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
93 fi
94 ;;
95 *)
f8d383ed 96 msg_usage "$0 {start|stop|restart|setup|status}"
42be133e
AG
97 exit 3
98esac
99
100exit $RETVAL
This page took 0.035591 seconds and 4 git commands to generate.