]> git.pld-linux.org Git - packages/VirtualBox.git/blame_incremental - VirtualBox-vboxguest.init
there is no 'vbox' group in guest, and chowning is not neccessary in guest
[packages/VirtualBox.git] / VirtualBox-vboxguest.init
... / ...
CommitLineData
1#!/bin/sh
2#
3# virtualbox VirtualBox virtualizer for x86 hardware
4#
5# chkconfig: 345 83 26
6#
7# description: Oracle 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_MODULE="vboxguest"
16VBOX_GUEST_DEVICE="/dev/vboxguest"
17VBOX_USER_DEVICE="/dev/vboxuser"
18
19# Get service config - may override defaults
20[ -f /etc/sysconfig/virtualbox ] && . /etc/sysconfig/virtualbox
21
22setup() {
23 local VBOX_MODULE=$1 VBOX_DEVICE=$2
24 modprobe -s $VBOX_MODULE
25 RETVAL=$?
26
27 if [ -d /dev/.udev ] || [ -d /run/udev/rules.d ]; then
28 return $RETVAL
29 fi
30
31 # set proper $VBOX_DEVICE for systems with static dev
32 show "Setting $VBOX_DEVICE entry"; busy
33 rm -f $VBOX_DEVICE
34 VBOX_MAJOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/devices)
35 if [ -n "$VBOX_MAJOR" ]; then
36 VBOX_MINOR=0
37 else
38 VBOX_MINOR=$(awk -vdevice="${VBOX_DEVICE#/dev/}" '$2 == device {print $1}' /proc/misc)
39 if [ -n "$VBOX_MINOR" ]; then
40 VBOX_MAJOR=$(awk '$2 == "misc" {print $1}' /proc/devices)
41 fi
42 fi
43
44 if [ -z "$VBOX_MAJOR" ]; then
45 /sbin/rmmod $VBOX_MODULE
46 RETVAL=1
47 elif ! mknod -m 0660 $VBOX_DEVICE c $VBOX_MAJOR $VBOX_MINOR; then
48 RETVAL=$?
49 rmmod $VBOX_MODNAME
50 fail
51 else
52 ok
53 fi
54 return $RETVAL
55}
56
57start() {
58 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
59 return
60 fi
61
62 setup $VBOX_MODULE $VBOX_GUEST_DEVICE || exit $?
63 setup $VBOX_MODULE $VBOX_USER_DEVICE || exit $?
64 touch /var/lock/subsys/$VBOX_MODULE
65}
66
67stop() {
68 # NOTE: rmmod will wait if device is in use, so automatic rmmod probably is not the best idea
69 /sbin/rmmod $VBOX_MODULE
70 rm -f /var/lock/subsys/$VBOX_MODULE
71}
72
73condrestart() {
74 if [ -f /var/lock/subsys/$VBOX_MODULE ]; then
75 stop
76 start
77 else
78 RETVAL=$1
79 fi
80}
81
82RETVAL=0
83# See how we were called.
84case "$1" in
85 start)
86 start
87 ;;
88 stop)
89 stop
90 ;;
91 restart)
92 stop
93 start
94 ;;
95 try-restart)
96 condrestart 0
97 ;;
98 force-reload)
99 condrestart 7
100 ;;
101 setup)
102 setup
103 ;;
104 status)
105 if ! is_module $VBOX_MODULE; then
106 echo "$VBOX_MODULE module is loaded"
107 else
108 echo "$VBOX_MODULE module is not loaded"
109 RETVAL=3
110 fi
111 if [ ! -c $VBOX_DEVICE ]; then
112 echo "$VBOX_DEVICE does not exist"
113 RETVAL=3
114 else
115 echo "$VBOX_DEVICE exists with major/minor $(ls -l $VBOX_DEVICE | awk '{print $5 $6}')"
116 fi
117 ;;
118 *)
119 msg_usage "$0 {start|stop|restart|try-restart|force-reload|setup|status}"
120 exit 3
121esac
122
123exit $RETVAL
This page took 0.036028 seconds and 4 git commands to generate.