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