1 | #! /bin/sh
|
---|
2 | #
|
---|
3 | # Linux Additions kernel module init script ($Revision: 39756 $)
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2010 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 |
|
---|
19 | # chkconfig: 357 30 70
|
---|
20 | # description: VirtualBox Linux Additions kernel modules
|
---|
21 | #
|
---|
22 | ### BEGIN INIT INFO
|
---|
23 | # Provides: vboxadd
|
---|
24 | # Required-Start:
|
---|
25 | # Required-Stop:
|
---|
26 | # Default-Start: 2 3 4 5
|
---|
27 | # Default-Stop: 0 1 6
|
---|
28 | # Description: VirtualBox Linux Additions kernel modules
|
---|
29 | ### END INIT INFO
|
---|
30 |
|
---|
31 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
32 | PACKAGE=VBoxGuestAdditions
|
---|
33 | LOG="/var/log/vboxadd-install.log"
|
---|
34 | MODPROBE=/sbin/modprobe
|
---|
35 | OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
|
---|
36 |
|
---|
37 | if $MODPROBE -c | grep -q '^allow_unsupported_modules *0'; then
|
---|
38 | MODPROBE="$MODPROBE --allow-unsupported-modules"
|
---|
39 | fi
|
---|
40 |
|
---|
41 | # Check architecture
|
---|
42 | cpu=`uname -m`;
|
---|
43 | case "$cpu" in
|
---|
44 | i[3456789]86|x86)
|
---|
45 | cpu="x86"
|
---|
46 | lib_path="/usr/lib"
|
---|
47 | ;;
|
---|
48 | x86_64|amd64)
|
---|
49 | cpu="amd64"
|
---|
50 | if test -d "/usr/lib64"; then
|
---|
51 | lib_path="/usr/lib64"
|
---|
52 | else
|
---|
53 | lib_path="/usr/lib"
|
---|
54 | fi
|
---|
55 | ;;
|
---|
56 | esac
|
---|
57 |
|
---|
58 | if [ -f /etc/arch-release ]; then
|
---|
59 | system=arch
|
---|
60 | elif [ -f /etc/redhat-release ]; then
|
---|
61 | system=redhat
|
---|
62 | elif [ -f /etc/SuSE-release ]; then
|
---|
63 | system=suse
|
---|
64 | elif [ -f /etc/gentoo-release ]; then
|
---|
65 | system=gentoo
|
---|
66 | elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
|
---|
67 | system=lfs
|
---|
68 | else
|
---|
69 | system=other
|
---|
70 | fi
|
---|
71 |
|
---|
72 | if [ "$system" = "arch" ]; then
|
---|
73 | USECOLOR=yes
|
---|
74 | . /etc/rc.d/functions
|
---|
75 | fail_msg() {
|
---|
76 | stat_fail
|
---|
77 | }
|
---|
78 |
|
---|
79 | succ_msg() {
|
---|
80 | stat_done
|
---|
81 | }
|
---|
82 |
|
---|
83 | begin() {
|
---|
84 | stat_busy "$1"
|
---|
85 | }
|
---|
86 | fi
|
---|
87 |
|
---|
88 | if [ "$system" = "redhat" ]; then
|
---|
89 | . /etc/init.d/functions
|
---|
90 | fail_msg() {
|
---|
91 | echo_failure
|
---|
92 | echo
|
---|
93 | }
|
---|
94 | succ_msg() {
|
---|
95 | echo_success
|
---|
96 | echo
|
---|
97 | }
|
---|
98 | begin() {
|
---|
99 | echo -n "$1"
|
---|
100 | }
|
---|
101 | fi
|
---|
102 |
|
---|
103 | if [ "$system" = "suse" ]; then
|
---|
104 | . /etc/rc.status
|
---|
105 | fail_msg() {
|
---|
106 | rc_failed 1
|
---|
107 | rc_status -v
|
---|
108 | }
|
---|
109 | succ_msg() {
|
---|
110 | rc_reset
|
---|
111 | rc_status -v
|
---|
112 | }
|
---|
113 | begin() {
|
---|
114 | echo -n "$1"
|
---|
115 | }
|
---|
116 | fi
|
---|
117 |
|
---|
118 | if [ "$system" = "gentoo" ]; then
|
---|
119 | if [ -f /sbin/functions.sh ]; then
|
---|
120 | . /sbin/functions.sh
|
---|
121 | elif [ -f /etc/init.d/functions.sh ]; then
|
---|
122 | . /etc/init.d/functions.sh
|
---|
123 | fi
|
---|
124 | fail_msg() {
|
---|
125 | eend 1
|
---|
126 | }
|
---|
127 | succ_msg() {
|
---|
128 | eend $?
|
---|
129 | }
|
---|
130 | begin() {
|
---|
131 | ebegin $1
|
---|
132 | }
|
---|
133 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
134 | shift
|
---|
135 | fi
|
---|
136 | fi
|
---|
137 |
|
---|
138 | if [ "$system" = "lfs" ]; then
|
---|
139 | . /etc/rc.d/init.d/functions
|
---|
140 | fail_msg() {
|
---|
141 | echo_failure
|
---|
142 | }
|
---|
143 | succ_msg() {
|
---|
144 | echo_ok
|
---|
145 | }
|
---|
146 | begin() {
|
---|
147 | echo $1
|
---|
148 | }
|
---|
149 | fi
|
---|
150 |
|
---|
151 | if [ "$system" = "other" ]; then
|
---|
152 | fail_msg() {
|
---|
153 | echo " ...fail!"
|
---|
154 | }
|
---|
155 | succ_msg() {
|
---|
156 | echo " ...done."
|
---|
157 | }
|
---|
158 | begin() {
|
---|
159 | echo -n $1
|
---|
160 | }
|
---|
161 | fi
|
---|
162 |
|
---|
163 | show_error()
|
---|
164 | {
|
---|
165 | if [ "$system" = "gentoo" ]; then
|
---|
166 | eerror $1
|
---|
167 | fi
|
---|
168 | fail_msg
|
---|
169 | echo "($1)"
|
---|
170 | }
|
---|
171 |
|
---|
172 | fail()
|
---|
173 | {
|
---|
174 | show_error "$1"
|
---|
175 | exit 1
|
---|
176 | }
|
---|
177 |
|
---|
178 | dev=/dev/vboxguest
|
---|
179 | userdev=/dev/vboxuser
|
---|
180 | config=/var/lib/VBoxGuestAdditions/config
|
---|
181 | owner=vboxadd
|
---|
182 | group=1
|
---|
183 |
|
---|
184 | test_for_gcc_and_make()
|
---|
185 | {
|
---|
186 | which make > /dev/null 2>&1 || printf "\nThe make utility was not found. If the following module compilation fails then\nthis could be the reason and you should try installing it.\n"
|
---|
187 | which gcc > /dev/null 2>&1 || printf "\nThe gcc utility was not found. If the following module compilation fails then\nthis could be the reason and you should try installing it.\n"
|
---|
188 | }
|
---|
189 |
|
---|
190 | test_sane_kernel_dir()
|
---|
191 | {
|
---|
192 | KERN_VER=`uname -r`
|
---|
193 | KERN_DIR="/lib/modules/$KERN_VER/build"
|
---|
194 | if [ -d "$KERN_DIR" ]; then
|
---|
195 | KERN_REL=`make -sC $KERN_DIR --no-print-directory kernelrelease 2>/dev/null || true`
|
---|
196 | if [ -z "$KERN_REL" -o "x$KERN_REL" = "x$KERN_VER" ]; then
|
---|
197 | return 0
|
---|
198 | fi
|
---|
199 | fi
|
---|
200 | printf "\nThe headers for the current running kernel were not found. If the following\nmodule compilation fails then this could be the reason.\n"
|
---|
201 | if [ "$system" = "redhat" ]; then
|
---|
202 | if echo "$KERN_VER" | grep -q "uek"; then
|
---|
203 | printf "The missing package can be probably installed with\nyum install kernel-uek-devel-$KERN_VER\n"
|
---|
204 | else
|
---|
205 | printf "The missing package can be probably installed with\nyum install kernel-devel-$KERN_VER\n"
|
---|
206 | fi
|
---|
207 | elif [ "$system" = "suse" ]; then
|
---|
208 | KERN_VER_SUSE=`echo "$KERN_VER" | sed 's/.*-\([^-]*\)/\1/g'`
|
---|
209 | KERN_VER_BASE=`echo "$KERN_VER" | sed 's/\(.*\)-[^-]*/\1/g'`
|
---|
210 | printf "The missing package can be probably installed with\nzypper install kernel-$KERN_VER_SUSE-devel-$KERN_VER_BASE\n"
|
---|
211 | elif [ "$system" = "debian" ]; then
|
---|
212 | printf "The missing package can be probably installed with\napt-get install linux-headers-$KERN_VER\n"
|
---|
213 | fi
|
---|
214 | }
|
---|
215 |
|
---|
216 | running_vboxguest()
|
---|
217 | {
|
---|
218 | lsmod | grep -q "vboxguest[^_-]"
|
---|
219 | }
|
---|
220 |
|
---|
221 | running_vboxadd()
|
---|
222 | {
|
---|
223 | lsmod | grep -q "vboxadd[^_-]"
|
---|
224 | }
|
---|
225 |
|
---|
226 | running_vboxsf()
|
---|
227 | {
|
---|
228 | lsmod | grep -q "vboxsf[^_-]"
|
---|
229 | }
|
---|
230 |
|
---|
231 | do_vboxguest_non_udev()
|
---|
232 | {
|
---|
233 | if [ ! -c $dev ]; then
|
---|
234 | maj=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/devices`
|
---|
235 | if [ ! -z "$maj" ]; then
|
---|
236 | min=0
|
---|
237 | else
|
---|
238 | min=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/misc`
|
---|
239 | if [ ! -z "$min" ]; then
|
---|
240 | maj=10
|
---|
241 | fi
|
---|
242 | fi
|
---|
243 | test -z "$maj" && {
|
---|
244 | rmmod vboxguest 2>/dev/null
|
---|
245 | fail "Cannot locate the VirtualBox device"
|
---|
246 | }
|
---|
247 |
|
---|
248 | mknod -m 0664 $dev c $maj $min || {
|
---|
249 | rmmod vboxguest 2>/dev/null
|
---|
250 | fail "Cannot create device $dev with major $maj and minor $min"
|
---|
251 | }
|
---|
252 | fi
|
---|
253 | chown $owner:$group $dev 2>/dev/null || {
|
---|
254 | rm -f $dev 2>/dev/null
|
---|
255 | rm -f $userdev 2>/dev/null
|
---|
256 | rmmod vboxguest 2>/dev/null
|
---|
257 | fail "Cannot change owner $owner:$group for device $dev"
|
---|
258 | }
|
---|
259 |
|
---|
260 | if [ ! -c $userdev ]; then
|
---|
261 | maj=10
|
---|
262 | min=`sed -n 's;\([0-9]\+\) vboxuser;\1;p' /proc/misc`
|
---|
263 | if [ ! -z "$min" ]; then
|
---|
264 | mknod -m 0666 $userdev c $maj $min || {
|
---|
265 | rm -f $dev 2>/dev/null
|
---|
266 | rmmod vboxguest 2>/dev/null
|
---|
267 | fail "Cannot create device $userdev with major $maj and minor $min"
|
---|
268 | }
|
---|
269 | chown $owner:$group $userdev 2>/dev/null || {
|
---|
270 | rm -f $dev 2>/dev/null
|
---|
271 | rm -f $userdev 2>/dev/null
|
---|
272 | rmmod vboxguest 2>/dev/null
|
---|
273 | fail "Cannot change owner $owner:$group for device $userdev"
|
---|
274 | }
|
---|
275 | fi
|
---|
276 | fi
|
---|
277 | }
|
---|
278 |
|
---|
279 | start()
|
---|
280 | {
|
---|
281 | begin "Starting the VirtualBox Guest Additions ";
|
---|
282 | uname -r | grep -q '^2\.6' 2>/dev/null &&
|
---|
283 | ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
|
---|
284 | no_udev=1
|
---|
285 | running_vboxguest || {
|
---|
286 | rm -f $dev || {
|
---|
287 | fail "Cannot remove $dev"
|
---|
288 | }
|
---|
289 |
|
---|
290 | rm -f $userdev || {
|
---|
291 | fail "Cannot remove $userdev"
|
---|
292 | }
|
---|
293 |
|
---|
294 | $MODPROBE vboxguest >/dev/null 2>&1 || {
|
---|
295 | fail "modprobe vboxguest failed"
|
---|
296 | }
|
---|
297 | case "$no_udev" in 1)
|
---|
298 | sleep .5;;
|
---|
299 | esac
|
---|
300 | }
|
---|
301 | case "$no_udev" in 1)
|
---|
302 | do_vboxguest_non_udev;;
|
---|
303 | esac
|
---|
304 |
|
---|
305 | running_vboxsf || {
|
---|
306 | $MODPROBE vboxsf > /dev/null 2>&1 || {
|
---|
307 | if dmesg | grep "vboxConnect failed" > /dev/null 2>&1; then
|
---|
308 | fail_msg
|
---|
309 | echo "Unable to start shared folders support. Make sure that your VirtualBox build"
|
---|
310 | echo "supports this feature."
|
---|
311 | exit 1
|
---|
312 | fi
|
---|
313 | fail "modprobe vboxsf failed"
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | # Mount all shared folders from /etc/fstab. Normally this is done by some
|
---|
318 | # other startup script but this requires the vboxdrv kernel module loaded.
|
---|
319 | # This isn't necessary anymore as the vboxsf module is autoloaded.
|
---|
320 | # mount -a -t vboxsf
|
---|
321 |
|
---|
322 | succ_msg
|
---|
323 | return 0
|
---|
324 | }
|
---|
325 |
|
---|
326 | stop()
|
---|
327 | {
|
---|
328 | begin "Stopping VirtualBox Additions ";
|
---|
329 | if ! umount -a -t vboxsf 2>/dev/null; then
|
---|
330 | fail "Cannot unmount vboxsf folders"
|
---|
331 | fi
|
---|
332 | if running_vboxsf; then
|
---|
333 | rmmod vboxsf 2>/dev/null || fail "Cannot unload module vboxsf"
|
---|
334 | fi
|
---|
335 | if running_vboxguest; then
|
---|
336 | rmmod vboxguest 2>/dev/null || fail "Cannot unload module vboxguest"
|
---|
337 | rm -f $userdev || fail "Cannot unlink $userdev"
|
---|
338 | rm -f $dev || fail "Cannot unlink $dev"
|
---|
339 | fi
|
---|
340 | succ_msg
|
---|
341 | return 0
|
---|
342 | }
|
---|
343 |
|
---|
344 | restart()
|
---|
345 | {
|
---|
346 | stop && start
|
---|
347 | return 0
|
---|
348 | }
|
---|
349 |
|
---|
350 | # Remove any existing VirtualBox guest kernel modules from the disk, but not
|
---|
351 | # from the kernel as they may still be in use
|
---|
352 | cleanup_modules()
|
---|
353 | {
|
---|
354 | begin "Removing existing VirtualBox DKMS kernel modules"
|
---|
355 | $DODKMS uninstall $OLDMODULES > $LOG
|
---|
356 | succ_msg
|
---|
357 | begin "Removing existing VirtualBox non-DKMS kernel modules"
|
---|
358 | for i in $OLDMODULES; do
|
---|
359 | find /lib/modules -name $i\* | xargs rm 2>/dev/null
|
---|
360 | done
|
---|
361 | succ_msg
|
---|
362 | }
|
---|
363 |
|
---|
364 | # Build and install the VirtualBox guest kernel modules
|
---|
365 | setup_modules()
|
---|
366 | {
|
---|
367 | # don't stop the old modules here -- they might be in use
|
---|
368 | cleanup_modules
|
---|
369 | begin "Building the VirtualBox Guest Additions kernel modules"
|
---|
370 |
|
---|
371 | # Short cut out if a dkms build succeeds
|
---|
372 | if $DODKMS install vboxguest $INSTALL_VER >> $LOG 2>&1; then
|
---|
373 | succ_msg
|
---|
374 | return 0
|
---|
375 | fi
|
---|
376 |
|
---|
377 | test_for_gcc_and_make
|
---|
378 | test_sane_kernel_dir
|
---|
379 |
|
---|
380 | echo
|
---|
381 | begin "Building the main Guest Additions module"
|
---|
382 | if ! $BUILDINTMP \
|
---|
383 | --save-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
384 | --module-source $MODULE_SRC/vboxguest \
|
---|
385 | --no-print-directory install >> $LOG 2>&1; then
|
---|
386 | show_error "Look at $LOG to find out what went wrong"
|
---|
387 | return 1
|
---|
388 | fi
|
---|
389 | succ_msg
|
---|
390 | begin "Building the shared folder support module"
|
---|
391 | if ! $BUILDINTMP \
|
---|
392 | --use-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
393 | --module-source $MODULE_SRC/vboxsf \
|
---|
394 | --no-print-directory install >> $LOG 2>&1; then
|
---|
395 | show_error "Look at $LOG to find out what went wrong"
|
---|
396 | return 1
|
---|
397 | fi
|
---|
398 | succ_msg
|
---|
399 | if expr `uname -r` '<' '2.6.27' > /dev/null; then
|
---|
400 | echo "Not building the VirtualBox advanced graphics driver as this Linux version is"
|
---|
401 | echo "too old to use it."
|
---|
402 | else
|
---|
403 | begin "Building the OpenGL support module"
|
---|
404 | if ! $BUILDINTMP \
|
---|
405 | --use-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
406 | --module-source $MODULE_SRC/vboxvideo \
|
---|
407 | --no-print-directory install >> $LOG 2>&1; then
|
---|
408 | show_error "Look at $LOG to find out what went wrong"
|
---|
409 | return 1
|
---|
410 | fi
|
---|
411 | succ_msg
|
---|
412 | fi
|
---|
413 | depmod
|
---|
414 | return 0
|
---|
415 | }
|
---|
416 |
|
---|
417 | # Do non-kernel bits needed for the kernel modules to work properly (user
|
---|
418 | # creation, udev, mount helper...)
|
---|
419 | extra_setup()
|
---|
420 | {
|
---|
421 | begin "Doing non-kernel setup of the Guest Additions"
|
---|
422 | echo "Creating user for the Guest Additions." >> $LOG
|
---|
423 | # This is the LSB version of useradd and should work on recent
|
---|
424 | # distributions
|
---|
425 | useradd -d /var/run/vboxadd -g 1 -r -s /bin/false vboxadd >/dev/null 2>&1
|
---|
426 | # And for the others, we choose a UID ourselves
|
---|
427 | useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1
|
---|
428 |
|
---|
429 | # Add a group "vboxsf" for Shared Folders access
|
---|
430 | # All users which want to access the auto-mounted Shared Folders have to
|
---|
431 | # be added to this group.
|
---|
432 | groupadd -f vboxsf >/dev/null 2>&1
|
---|
433 |
|
---|
434 | # Create udev description file
|
---|
435 | if [ -d /etc/udev/rules.d ]; then
|
---|
436 | echo "Creating udev rule for the Guest Additions kernel module." >> $LOG
|
---|
437 | udev_call=""
|
---|
438 | udev_app=`which udevadm 2> /dev/null`
|
---|
439 | if [ $? -eq 0 ]; then
|
---|
440 | udev_call="${udev_app} version 2> /dev/null"
|
---|
441 | else
|
---|
442 | udev_app=`which udevinfo 2> /dev/null`
|
---|
443 | if [ $? -eq 0 ]; then
|
---|
444 | udev_call="${udev_app} -V 2> /dev/null"
|
---|
445 | fi
|
---|
446 | fi
|
---|
447 | udev_fix="="
|
---|
448 | if [ "${udev_call}" != "" ]; then
|
---|
449 | udev_out=`${udev_call}`
|
---|
450 | udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
|
---|
451 | if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
|
---|
452 | udev_fix=""
|
---|
453 | fi
|
---|
454 | fi
|
---|
455 | ## @todo 60-vboxadd.rules -> 60-vboxguest.rules ?
|
---|
456 | echo "KERNEL=${udev_fix}\"vboxguest\", NAME=\"vboxguest\", OWNER=\"vboxadd\", MODE=\"0660\"" > /etc/udev/rules.d/60-vboxadd.rules
|
---|
457 | echo "KERNEL=${udev_fix}\"vboxuser\", NAME=\"vboxuser\", OWNER=\"vboxadd\", MODE=\"0666\"" >> /etc/udev/rules.d/60-vboxadd.rules
|
---|
458 | fi
|
---|
459 |
|
---|
460 | # Put mount.vboxsf in the right place
|
---|
461 | ln -sf "$lib_path/$PACKAGE/mount.vboxsf" /sbin
|
---|
462 | # At least Fedora 11 and Fedora 12 require the correct security context when
|
---|
463 | # executing this command from service scripts. Shouldn't hurt for other
|
---|
464 | # distributions.
|
---|
465 | chcon -u system_u -t mount_exec_t "$lib_path/$PACKAGE/mount.vboxsf" > /dev/null 2>&1
|
---|
466 | # And at least Fedora 15 needs this for the acceleration support check to
|
---|
467 | # work
|
---|
468 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
---|
469 | case "$redhat_release" in Fedora\ release\ 15* )
|
---|
470 | for i in "$lib_path"/*.so
|
---|
471 | do
|
---|
472 | restorecon "$i" >/dev/null
|
---|
473 | done
|
---|
474 | ;;
|
---|
475 | esac
|
---|
476 |
|
---|
477 | succ_msg
|
---|
478 | }
|
---|
479 |
|
---|
480 | # setup_script
|
---|
481 | setup()
|
---|
482 | {
|
---|
483 | if test -r $config; then
|
---|
484 | . $config
|
---|
485 | else
|
---|
486 | fail "Configuration file $config not found"
|
---|
487 | fi
|
---|
488 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
489 | fail "Configuration file $config not complete"
|
---|
490 | export BUILD_TYPE
|
---|
491 | export USERNAME
|
---|
492 |
|
---|
493 | MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
|
---|
494 | BUILDINTMP="$MODULE_SRC/build_in_tmp"
|
---|
495 | DODKMS="$MODULE_SRC/do_dkms"
|
---|
496 | chcon -t bin_t "$BUILDINTMP" > /dev/null 2>&1
|
---|
497 | chcon -t bin_t "$DODKMS" > /dev/null 2>&1
|
---|
498 |
|
---|
499 | setup_modules
|
---|
500 | mod_succ="$?"
|
---|
501 | extra_setup
|
---|
502 | if [ "$mod_succ" -eq "0" ]; then
|
---|
503 | if running_vboxguest || running_vboxadd; then
|
---|
504 | printf "You should restart your guest to make sure the new modules are actually used\n\n"
|
---|
505 | else
|
---|
506 | start
|
---|
507 | fi
|
---|
508 | fi
|
---|
509 | }
|
---|
510 |
|
---|
511 | # cleanup_script
|
---|
512 | cleanup()
|
---|
513 | {
|
---|
514 | if test -r $config; then
|
---|
515 | . $config
|
---|
516 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
517 | fail "Configuration file $config not complete"
|
---|
518 | DODKMS="$INSTALL_DIR/src/vboxguest-$INSTALL_VER/do_dkms"
|
---|
519 | elif test -x ./do_dkms; then # Executing as part of the installer...
|
---|
520 | DODKMS=./do_dkms
|
---|
521 | else
|
---|
522 | fail "Configuration file $config not found"
|
---|
523 | fi
|
---|
524 |
|
---|
525 | # Delete old versions of VBox modules.
|
---|
526 | cleanup_modules
|
---|
527 | depmod
|
---|
528 |
|
---|
529 | # Remove old module sources
|
---|
530 | for i in $OLDMODULES; do
|
---|
531 | rm -rf /usr/src/$i-*
|
---|
532 | done
|
---|
533 |
|
---|
534 | # Remove other files
|
---|
535 | rm /sbin/mount.vboxsf 2>/dev/null
|
---|
536 | rm /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null
|
---|
537 | }
|
---|
538 |
|
---|
539 | dmnstatus()
|
---|
540 | {
|
---|
541 | if running_vboxguest; then
|
---|
542 | echo "The VirtualBox Additions are currently running."
|
---|
543 | else
|
---|
544 | echo "The VirtualBox Additions are not currently running."
|
---|
545 | fi
|
---|
546 | }
|
---|
547 |
|
---|
548 | case "$1" in
|
---|
549 | start)
|
---|
550 | start
|
---|
551 | ;;
|
---|
552 | stop)
|
---|
553 | stop
|
---|
554 | ;;
|
---|
555 | restart)
|
---|
556 | restart
|
---|
557 | ;;
|
---|
558 | setup)
|
---|
559 | setup
|
---|
560 | ;;
|
---|
561 | cleanup)
|
---|
562 | cleanup
|
---|
563 | ;;
|
---|
564 | status)
|
---|
565 | dmnstatus
|
---|
566 | ;;
|
---|
567 | *)
|
---|
568 | echo "Usage: $0 {start|stop|restart|status|setup}"
|
---|
569 | exit 1
|
---|
570 | esac
|
---|
571 |
|
---|
572 | exit
|
---|