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