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