1 | #! /bin/sh
|
---|
2 | # InnoTek VirtualBox
|
---|
3 | # Linux Additions VFS kernel module init script
|
---|
4 | #
|
---|
5 | # Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
6 | #
|
---|
7 | # Use only with permission.
|
---|
8 | #
|
---|
9 |
|
---|
10 |
|
---|
11 | # chkconfig: 35 30 60
|
---|
12 | # description: VirtualBox Linux Additions VFS kernel module
|
---|
13 | #
|
---|
14 | ### BEGIN INIT INFO
|
---|
15 | # Provides: vboxvfs
|
---|
16 | # Required-Start: vboxadd
|
---|
17 | # Required-Stop:
|
---|
18 | # Default-Start: 3 5
|
---|
19 | # Default-Stop:
|
---|
20 | # Description: VirtualBox Linux Additions VFS kernel module
|
---|
21 | ### END INIT INFO
|
---|
22 |
|
---|
23 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
24 |
|
---|
25 | if [ -f /etc/redhat-release ]; then
|
---|
26 | system=redhat
|
---|
27 | elif [ -f /etc/SuSE-release ]; then
|
---|
28 | system=suse
|
---|
29 | elif [ -f /etc/gentoo-release ]; then
|
---|
30 | system=gentoo
|
---|
31 | else
|
---|
32 | system=other
|
---|
33 | fi
|
---|
34 |
|
---|
35 | if [ "$system" = "redhat" ]; then
|
---|
36 | . /etc/init.d/functions
|
---|
37 | fail_msg() {
|
---|
38 | echo_failure
|
---|
39 | echo
|
---|
40 | }
|
---|
41 |
|
---|
42 | succ_msg() {
|
---|
43 | echo_success
|
---|
44 | echo
|
---|
45 | }
|
---|
46 |
|
---|
47 | begin() {
|
---|
48 | echo -n "$1"
|
---|
49 | }
|
---|
50 | fi
|
---|
51 |
|
---|
52 | if [ "$system" = "suse" ]; then
|
---|
53 | . /etc/rc.status
|
---|
54 | fail_msg() {
|
---|
55 | rc_failed 1
|
---|
56 | rc_status -v
|
---|
57 | }
|
---|
58 |
|
---|
59 | succ_msg() {
|
---|
60 | rc_reset
|
---|
61 | rc_status -v
|
---|
62 | }
|
---|
63 |
|
---|
64 | begin() {
|
---|
65 | echo -n "$1"
|
---|
66 | }
|
---|
67 | fi
|
---|
68 |
|
---|
69 | if [ "$system" = "gentoo" ]; then
|
---|
70 | . /sbin/functions.sh
|
---|
71 | fail_msg() {
|
---|
72 | eend 1
|
---|
73 | }
|
---|
74 |
|
---|
75 | succ_msg() {
|
---|
76 | eend $?
|
---|
77 | }
|
---|
78 |
|
---|
79 | begin() {
|
---|
80 | ebegin $1
|
---|
81 | }
|
---|
82 |
|
---|
83 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
84 | shift
|
---|
85 | fi
|
---|
86 | fi
|
---|
87 |
|
---|
88 | if [ "$system" = "other" ]; then
|
---|
89 | fail_msg() {
|
---|
90 | echo " ...fail!"
|
---|
91 | }
|
---|
92 |
|
---|
93 | succ_msg() {
|
---|
94 | echo " ...done."
|
---|
95 | }
|
---|
96 |
|
---|
97 | begin() {
|
---|
98 | echo -n $1
|
---|
99 | }
|
---|
100 | fi
|
---|
101 |
|
---|
102 | kdir=/lib/modules/`uname -r`/misc
|
---|
103 | modname=vboxvfs
|
---|
104 | module="$kdir/$modname"
|
---|
105 |
|
---|
106 | file=""
|
---|
107 | test -f $module.o && file=$module.o
|
---|
108 | test -f $module.ko && file=$module.ko
|
---|
109 |
|
---|
110 | fail() {
|
---|
111 | if [ "$system" = "gentoo" ]; then
|
---|
112 | eerror $1
|
---|
113 | exit 1
|
---|
114 | fi
|
---|
115 | fail_msg
|
---|
116 | echo "($1)"
|
---|
117 | exit 1
|
---|
118 | }
|
---|
119 |
|
---|
120 | test -z "$file" && {
|
---|
121 | fail "Kernel module not found"
|
---|
122 | }
|
---|
123 |
|
---|
124 | running() {
|
---|
125 | lsmod | grep -q $modname[^_-]
|
---|
126 | }
|
---|
127 |
|
---|
128 | start() {
|
---|
129 | begin "Starting VirtualBox Additions shared folder support ";
|
---|
130 | running || {
|
---|
131 | modprobe $modname > /dev/null 2>&1 || {
|
---|
132 | if dmesg | grep "vboxConnect failed" > /dev/null 2>&1; then
|
---|
133 | fail_msg
|
---|
134 | echo "You may be trying to run Guest Additions from binary release of VirtualBox"
|
---|
135 | echo "in the Open Source Edition."
|
---|
136 | exit 1
|
---|
137 | fi
|
---|
138 | fail "modprobe $modname failed"
|
---|
139 | }
|
---|
140 | }
|
---|
141 | succ_msg
|
---|
142 | return 0
|
---|
143 | }
|
---|
144 |
|
---|
145 | stop() {
|
---|
146 | begin "Stopping VirtualBox Additions shared folder support ";
|
---|
147 | if running; then
|
---|
148 | rmmod $modname || fail "Cannot unload module $modname"
|
---|
149 | fi
|
---|
150 | succ_msg
|
---|
151 | return 0
|
---|
152 | }
|
---|
153 |
|
---|
154 | restart() {
|
---|
155 | stop && start
|
---|
156 | return 0
|
---|
157 | }
|
---|
158 |
|
---|
159 | dmnstatus() {
|
---|
160 | if running; then
|
---|
161 | echo "VirtualBox Additions shared folder support is currently running."
|
---|
162 | else
|
---|
163 | echo "VirtualBox Additions shared folder support is not currently running."
|
---|
164 | fi
|
---|
165 | }
|
---|
166 |
|
---|
167 | case "$1" in
|
---|
168 | start)
|
---|
169 | start
|
---|
170 | ;;
|
---|
171 | stop)
|
---|
172 | stop
|
---|
173 | ;;
|
---|
174 | restart)
|
---|
175 | restart
|
---|
176 | ;;
|
---|
177 | status)
|
---|
178 | dmnstatus
|
---|
179 | ;;
|
---|
180 | *)
|
---|
181 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
182 | exit 1
|
---|
183 | esac
|
---|
184 |
|
---|
185 | exit
|
---|