1 | #! /bin/sh
|
---|
2 | #
|
---|
3 | # Linux Additions kernel module init script ($Revision: 61206 $)
|
---|
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: 345 10 90
|
---|
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 | ## @todo This file duplicates a lot of script with vboxdrv.sh. When making
|
---|
32 | # changes please try to reduce differences between the two wherever possible.
|
---|
33 |
|
---|
34 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
35 | PACKAGE=VBoxGuestAdditions
|
---|
36 | LOG="/var/log/vboxadd-install.log"
|
---|
37 | MODPROBE=/sbin/modprobe
|
---|
38 | OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
|
---|
39 | SCRIPTNAME=vboxadd.sh
|
---|
40 | QUICKSETUP=
|
---|
41 |
|
---|
42 | if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules *0'; then
|
---|
43 | MODPROBE="$MODPROBE --allow-unsupported-modules"
|
---|
44 | fi
|
---|
45 |
|
---|
46 | # Check architecture
|
---|
47 | cpu=`uname -m`;
|
---|
48 | case "$cpu" in
|
---|
49 | i[3456789]86|x86)
|
---|
50 | cpu="x86"
|
---|
51 | ldconfig_arch="(libc6)"
|
---|
52 | lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"
|
---|
53 | ;;
|
---|
54 | x86_64|amd64)
|
---|
55 | cpu="amd64"
|
---|
56 | ldconfig_arch="(libc6,x86-64)"
|
---|
57 | lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"
|
---|
58 | ;;
|
---|
59 | esac
|
---|
60 | for i in $lib_candidates; do
|
---|
61 | if test -d "$i/VBoxGuestAdditions"; then
|
---|
62 | lib_path=$i
|
---|
63 | break
|
---|
64 | fi
|
---|
65 | done
|
---|
66 |
|
---|
67 | # Preamble for Gentoo
|
---|
68 | if [ "`which $0`" = "/sbin/rc" ]; then
|
---|
69 | shift
|
---|
70 | fi
|
---|
71 |
|
---|
72 | begin()
|
---|
73 | {
|
---|
74 | test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
|
---|
75 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
76 | }
|
---|
77 |
|
---|
78 | succ_msg()
|
---|
79 | {
|
---|
80 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
81 | }
|
---|
82 |
|
---|
83 | show_error()
|
---|
84 | {
|
---|
85 | echo "${SCRIPTNAME}: failed: ${1}." >&2
|
---|
86 | logger -t "${SCRIPTNAME}" "${1}."
|
---|
87 | }
|
---|
88 |
|
---|
89 | fail()
|
---|
90 | {
|
---|
91 | show_error "$1"
|
---|
92 | exit 1
|
---|
93 | }
|
---|
94 |
|
---|
95 | dev=/dev/vboxguest
|
---|
96 | userdev=/dev/vboxuser
|
---|
97 | config=/var/lib/VBoxGuestAdditions/config
|
---|
98 | owner=vboxadd
|
---|
99 | group=1
|
---|
100 |
|
---|
101 | running_vboxguest()
|
---|
102 | {
|
---|
103 | lsmod | grep -q "vboxguest[^_-]"
|
---|
104 | }
|
---|
105 |
|
---|
106 | running_vboxadd()
|
---|
107 | {
|
---|
108 | lsmod | grep -q "vboxadd[^_-]"
|
---|
109 | }
|
---|
110 |
|
---|
111 | running_vboxsf()
|
---|
112 | {
|
---|
113 | lsmod | grep -q "vboxsf[^_-]"
|
---|
114 | }
|
---|
115 |
|
---|
116 | running_vboxvideo()
|
---|
117 | {
|
---|
118 | lsmod | grep -q "vboxvideo[^_-]"
|
---|
119 | }
|
---|
120 |
|
---|
121 | do_vboxguest_non_udev()
|
---|
122 | {
|
---|
123 | if [ ! -c $dev ]; then
|
---|
124 | maj=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/devices`
|
---|
125 | if [ ! -z "$maj" ]; then
|
---|
126 | min=0
|
---|
127 | else
|
---|
128 | min=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/misc`
|
---|
129 | if [ ! -z "$min" ]; then
|
---|
130 | maj=10
|
---|
131 | fi
|
---|
132 | fi
|
---|
133 | test -z "$maj" && {
|
---|
134 | rmmod vboxguest 2>/dev/null
|
---|
135 | fail "Cannot locate the VirtualBox device"
|
---|
136 | }
|
---|
137 |
|
---|
138 | mknod -m 0664 $dev c $maj $min || {
|
---|
139 | rmmod vboxguest 2>/dev/null
|
---|
140 | fail "Cannot create device $dev with major $maj and minor $min"
|
---|
141 | }
|
---|
142 | fi
|
---|
143 | chown $owner:$group $dev 2>/dev/null || {
|
---|
144 | rm -f $dev 2>/dev/null
|
---|
145 | rm -f $userdev 2>/dev/null
|
---|
146 | rmmod vboxguest 2>/dev/null
|
---|
147 | fail "Cannot change owner $owner:$group for device $dev"
|
---|
148 | }
|
---|
149 |
|
---|
150 | if [ ! -c $userdev ]; then
|
---|
151 | maj=10
|
---|
152 | min=`sed -n 's;\([0-9]\+\) vboxuser;\1;p' /proc/misc`
|
---|
153 | if [ ! -z "$min" ]; then
|
---|
154 | mknod -m 0666 $userdev c $maj $min || {
|
---|
155 | rm -f $dev 2>/dev/null
|
---|
156 | rmmod vboxguest 2>/dev/null
|
---|
157 | fail "Cannot create device $userdev with major $maj and minor $min"
|
---|
158 | }
|
---|
159 | chown $owner:$group $userdev 2>/dev/null || {
|
---|
160 | rm -f $dev 2>/dev/null
|
---|
161 | rm -f $userdev 2>/dev/null
|
---|
162 | rmmod vboxguest 2>/dev/null
|
---|
163 | fail "Cannot change owner $owner:$group for device $userdev"
|
---|
164 | }
|
---|
165 | fi
|
---|
166 | fi
|
---|
167 | }
|
---|
168 |
|
---|
169 | start()
|
---|
170 | {
|
---|
171 | begin "Starting the VirtualBox Guest Additions" console;
|
---|
172 | # If we got this far assume that the slow set-up has been done.
|
---|
173 | QUICKSETUP=yes
|
---|
174 | if test -r $config; then
|
---|
175 | . $config
|
---|
176 | else
|
---|
177 | fail "Configuration file $config not found"
|
---|
178 | fi
|
---|
179 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
180 | fail "Configuration file $config not complete"
|
---|
181 | uname -r | grep -q -E '^2\.6|^3|^4' 2>/dev/null &&
|
---|
182 | ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
|
---|
183 | no_udev=1
|
---|
184 | running_vboxguest || {
|
---|
185 | rm -f $dev || {
|
---|
186 | fail "Cannot remove $dev"
|
---|
187 | }
|
---|
188 |
|
---|
189 | rm -f $userdev || {
|
---|
190 | fail "Cannot remove $userdev"
|
---|
191 | }
|
---|
192 |
|
---|
193 | $MODPROBE vboxguest >/dev/null 2>&1 || {
|
---|
194 | setup
|
---|
195 | $MODPROBE vboxguest >/dev/null 2>&1 || {
|
---|
196 | /sbin/rcvboxadd-x11 cleanup
|
---|
197 | fail "modprobe vboxguest failed"
|
---|
198 | }
|
---|
199 | }
|
---|
200 | case "$no_udev" in 1)
|
---|
201 | sleep .5;;
|
---|
202 | esac
|
---|
203 | }
|
---|
204 | case "$no_udev" in 1)
|
---|
205 | do_vboxguest_non_udev;;
|
---|
206 | esac
|
---|
207 |
|
---|
208 | running_vboxsf || {
|
---|
209 | $MODPROBE vboxsf > /dev/null 2>&1 || {
|
---|
210 | if dmesg | grep "VbglR0SfConnect failed" > /dev/null 2>&1; then
|
---|
211 | show_error "Unable to start shared folders support. Make sure that your VirtualBox build"
|
---|
212 | show_error "supports this feature."
|
---|
213 | else
|
---|
214 | show_error "modprobe vboxsf failed"
|
---|
215 | fi
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | # Put the X.Org driver in place. This is harmless if it is not needed.
|
---|
220 | /sbin/rcvboxadd-x11 setup
|
---|
221 | # Install the guest OpenGL drivers. For now we don't support
|
---|
222 | # multi-architecture installations
|
---|
223 | if /usr/bin/VBoxClient --check3d 2>/dev/null; then
|
---|
224 | rm -f /var/lib/VBoxGuestAdditions/lib/system/tmp.so
|
---|
225 | mkdir -m 0755 -p /var/lib/VBoxGuestAdditions/lib/system
|
---|
226 | ldconfig -p | while read -r line; do
|
---|
227 | case "${line}" in "libGL.so.1 ${ldconfig_arch} => "*)
|
---|
228 | ln -s "${line#libGL.so.1 ${ldconfig_arch} => }" /var/lib/VBoxGuestAdditions/lib/system/tmp.so
|
---|
229 | mv /var/lib/VBoxGuestAdditions/lib/system/tmp.so /var/lib/VBoxGuestAdditions/lib/system/libGL.so.1
|
---|
230 | break
|
---|
231 | esac
|
---|
232 | done
|
---|
233 | ldconfig -p | while read -r line; do
|
---|
234 | case "${line}" in "libEGL.so.1 ${ldconfig_arch} => "*)
|
---|
235 | ln -s "${line#libEGL.so.1 ${ldconfig_arch} => }" /var/lib/VBoxGuestAdditions/lib/system/tmp.so
|
---|
236 | mv /var/lib/VBoxGuestAdditions/lib/system/tmp.so /var/lib/VBoxGuestAdditions/lib/system/libEGL.so.1
|
---|
237 | break
|
---|
238 | esac
|
---|
239 | done
|
---|
240 | ln -sf "${INSTALL_DIR}/lib/VBoxOGL.so" /var/lib/VBoxGuestAdditions/lib/libGL.so.1
|
---|
241 | ln -sf "${INSTALL_DIR}/lib/VBoxEGL.so" /var/lib/VBoxGuestAdditions/lib/libEGL.so.1
|
---|
242 | echo "/var/lib/VBoxGuestAdditions/lib" > /etc/ld.so.conf.d/00vboxvideo.conf
|
---|
243 | else
|
---|
244 | rm -f /etc/ld.so.conf.d/00vboxvideo.conf
|
---|
245 | fi
|
---|
246 | ldconfig
|
---|
247 |
|
---|
248 | # Mount all shared folders from /etc/fstab. Normally this is done by some
|
---|
249 | # other startup script but this requires the vboxdrv kernel module loaded.
|
---|
250 | # This isn't necessary anymore as the vboxsf module is autoloaded.
|
---|
251 | # mount -a -t vboxsf
|
---|
252 |
|
---|
253 | succ_msg
|
---|
254 | return 0
|
---|
255 | }
|
---|
256 |
|
---|
257 | stop()
|
---|
258 | {
|
---|
259 | begin "Stopping VirtualBox Additions" console;
|
---|
260 | if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then
|
---|
261 | rm /etc/ld.so.conf.d/00vboxvideo.conf
|
---|
262 | ldconfig
|
---|
263 | fi
|
---|
264 | if ! umount -a -t vboxsf 2>/dev/null; then
|
---|
265 | fail "Cannot unmount vboxsf folders"
|
---|
266 | fi
|
---|
267 | if running_vboxsf; then
|
---|
268 | rmmod vboxsf 2>/dev/null || fail "Cannot unload module vboxsf"
|
---|
269 | fi
|
---|
270 | if running_vboxguest; then
|
---|
271 | rmmod vboxguest 2>/dev/null || fail "Cannot unload module vboxguest"
|
---|
272 | rm -f $userdev || fail "Cannot unlink $userdev"
|
---|
273 | rm -f $dev || fail "Cannot unlink $dev"
|
---|
274 | fi
|
---|
275 | succ_msg
|
---|
276 | return 0
|
---|
277 | }
|
---|
278 |
|
---|
279 | restart()
|
---|
280 | {
|
---|
281 | stop && start
|
---|
282 | return 0
|
---|
283 | }
|
---|
284 |
|
---|
285 | # Remove any existing VirtualBox guest kernel modules from the disk, but not
|
---|
286 | # from the kernel as they may still be in use
|
---|
287 | cleanup_modules()
|
---|
288 | {
|
---|
289 | begin "Removing existing VirtualBox kernel modules"
|
---|
290 | # We no longer support DKMS, remove any leftovers.
|
---|
291 | for i in vboxguest vboxadd vboxsf vboxvfs vboxvideo; do
|
---|
292 | rm -rf "/var/lib/dkms/${i}"*
|
---|
293 | done
|
---|
294 | for i in $OLDMODULES; do
|
---|
295 | find /lib/modules -name $i\* | xargs rm 2>/dev/null
|
---|
296 | done
|
---|
297 | # Remove leftover module folders.
|
---|
298 | for i in /lib/modules/*/misc; do
|
---|
299 | test -d "${i}" && rmdir -p "${i}" 2>/dev/null
|
---|
300 | done
|
---|
301 | succ_msg
|
---|
302 | }
|
---|
303 |
|
---|
304 | # Build and install the VirtualBox guest kernel modules
|
---|
305 | setup_modules()
|
---|
306 | {
|
---|
307 | # don't stop the old modules here -- they might be in use
|
---|
308 | test -z "${QUICKSETUP}" && cleanup_modules
|
---|
309 | # This does not work for 2.4 series kernels. How sad.
|
---|
310 | test -n "${QUICKSETUP}" && test -f "${MODULE_DIR}/vboxguest.ko" && return 0
|
---|
311 | begin "Building the VirtualBox Guest Additions kernel modules"
|
---|
312 |
|
---|
313 | begin "Building the main Guest Additions module"
|
---|
314 | if ! $BUILDINTMP \
|
---|
315 | --save-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
316 | --module-source $MODULE_SRC/vboxguest \
|
---|
317 | --no-print-directory install >> $LOG 2>&1; then
|
---|
318 | show_error "Look at $LOG to find out what went wrong"
|
---|
319 | return 1
|
---|
320 | fi
|
---|
321 | succ_msg
|
---|
322 | begin "Building the shared folder support module"
|
---|
323 | if ! $BUILDINTMP \
|
---|
324 | --use-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
325 | --module-source $MODULE_SRC/vboxsf \
|
---|
326 | --no-print-directory install >> $LOG 2>&1; then
|
---|
327 | show_error "Look at $LOG to find out what went wrong"
|
---|
328 | return 1
|
---|
329 | fi
|
---|
330 | succ_msg
|
---|
331 | begin "Building the graphics driver module"
|
---|
332 | if ! $BUILDINTMP \
|
---|
333 | --use-module-symvers /tmp/vboxguest-Module.symvers \
|
---|
334 | --module-source $MODULE_SRC/vboxvideo \
|
---|
335 | --no-print-directory install >> $LOG 2>&1; then
|
---|
336 | show_error "Look at $LOG to find out what went wrong"
|
---|
337 | fi
|
---|
338 | succ_msg
|
---|
339 | depmod
|
---|
340 | return 0
|
---|
341 | }
|
---|
342 |
|
---|
343 | # Do non-kernel bits needed for the kernel modules to work properly (user
|
---|
344 | # creation, udev, mount helper...)
|
---|
345 | extra_setup()
|
---|
346 | {
|
---|
347 | begin "Doing non-kernel setup of the Guest Additions"
|
---|
348 | echo "Creating user for the Guest Additions." >> $LOG
|
---|
349 | # This is the LSB version of useradd and should work on recent
|
---|
350 | # distributions
|
---|
351 | useradd -d /var/run/vboxadd -g 1 -r -s /bin/false vboxadd >/dev/null 2>&1
|
---|
352 | # And for the others, we choose a UID ourselves
|
---|
353 | useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1
|
---|
354 |
|
---|
355 | # Add a group "vboxsf" for Shared Folders access
|
---|
356 | # All users which want to access the auto-mounted Shared Folders have to
|
---|
357 | # be added to this group.
|
---|
358 | groupadd -r -f vboxsf >/dev/null 2>&1
|
---|
359 |
|
---|
360 | # Create udev description file
|
---|
361 | if [ -d /etc/udev/rules.d ]; then
|
---|
362 | echo "Creating udev rule for the Guest Additions kernel module." >> $LOG
|
---|
363 | udev_call=""
|
---|
364 | udev_app=`which udevadm 2> /dev/null`
|
---|
365 | if [ $? -eq 0 ]; then
|
---|
366 | udev_call="${udev_app} version 2> /dev/null"
|
---|
367 | else
|
---|
368 | udev_app=`which udevinfo 2> /dev/null`
|
---|
369 | if [ $? -eq 0 ]; then
|
---|
370 | udev_call="${udev_app} -V 2> /dev/null"
|
---|
371 | fi
|
---|
372 | fi
|
---|
373 | udev_fix="="
|
---|
374 | if [ "${udev_call}" != "" ]; then
|
---|
375 | udev_out=`${udev_call}`
|
---|
376 | udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
|
---|
377 | if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
|
---|
378 | udev_fix=""
|
---|
379 | fi
|
---|
380 | fi
|
---|
381 | ## @todo 60-vboxadd.rules -> 60-vboxguest.rules ?
|
---|
382 | echo "KERNEL=${udev_fix}\"vboxguest\", NAME=\"vboxguest\", OWNER=\"vboxadd\", MODE=\"0660\"" > /etc/udev/rules.d/60-vboxadd.rules
|
---|
383 | echo "KERNEL=${udev_fix}\"vboxuser\", NAME=\"vboxuser\", OWNER=\"vboxadd\", MODE=\"0666\"" >> /etc/udev/rules.d/60-vboxadd.rules
|
---|
384 | fi
|
---|
385 |
|
---|
386 | # Put mount.vboxsf in the right place
|
---|
387 | ln -sf "$lib_path/$PACKAGE/mount.vboxsf" /sbin
|
---|
388 | # And an rc file to re-build the kernel modules and re-set-up the X server.
|
---|
389 | ln -sf "$lib_path/$PACKAGE/vboxadd" /sbin/rcvboxadd
|
---|
390 | ln -sf "$lib_path/$PACKAGE/vboxadd-x11" /sbin/rcvboxadd-x11
|
---|
391 | # And a post-installation script for rebuilding modules when a new kernel
|
---|
392 | # is installed.
|
---|
393 | mkdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d
|
---|
394 | cat << EOF > /etc/kernel/postinst.d/vboxadd
|
---|
395 | #!/bin/sh
|
---|
396 | test -d "/lib/modules/\${1}/build" || exit 0
|
---|
397 | KERN_DIR="/lib/modules/\${1}/build" MODULE_DIR="/lib/modules/\${1}/misc" \
|
---|
398 | /sbin/rcvboxadd quicksetup
|
---|
399 | exit 0
|
---|
400 | EOF
|
---|
401 | cat << EOF > /etc/kernel/prerm.d/vboxadd
|
---|
402 | #!/bin/sh
|
---|
403 | for i in ${OLDMODULES}; do rm -f /lib/modules/"\${1}"/misc/"\${i}".ko; done
|
---|
404 | rmdir -p /lib/modules/"\$1"/misc 2>/dev/null
|
---|
405 | exit 0
|
---|
406 | EOF
|
---|
407 | chmod 0755 /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
|
---|
408 | # At least Fedora 11 and Fedora 12 require the correct security context when
|
---|
409 | # executing this command from service scripts. Shouldn't hurt for other
|
---|
410 | # distributions.
|
---|
411 | chcon -u system_u -t mount_exec_t "$lib_path/$PACKAGE/mount.vboxsf" > /dev/null 2>&1
|
---|
412 | # And at least Fedora 15 needs this for the acceleration support check to
|
---|
413 | # work
|
---|
414 | redhat_release=`cat /etc/redhat-release 2> /dev/null`
|
---|
415 | case "$redhat_release" in Fedora\ release\ 15* )
|
---|
416 | for i in "$lib_path"/*.so
|
---|
417 | do
|
---|
418 | restorecon "$i" >/dev/null
|
---|
419 | done
|
---|
420 | ;;
|
---|
421 | esac
|
---|
422 |
|
---|
423 | succ_msg
|
---|
424 | }
|
---|
425 |
|
---|
426 | # setup_script
|
---|
427 | setup()
|
---|
428 | {
|
---|
429 | begin "Building Guest Additions kernel modules" console
|
---|
430 | if test -r $config; then
|
---|
431 | . $config
|
---|
432 | else
|
---|
433 | fail "Configuration file $config not found"
|
---|
434 | fi
|
---|
435 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
436 | fail "Configuration file $config not complete"
|
---|
437 | export BUILD_TYPE
|
---|
438 | export USERNAME
|
---|
439 |
|
---|
440 | rm -f $LOG
|
---|
441 | MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
|
---|
442 | BUILDINTMP="$MODULE_SRC/build_in_tmp"
|
---|
443 | chcon -t bin_t "$BUILDINTMP" > /dev/null 2>&1
|
---|
444 |
|
---|
445 | if setup_modules; then
|
---|
446 | mod_succ=0
|
---|
447 | else
|
---|
448 | mod_succ=1
|
---|
449 | show_error "Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed."
|
---|
450 | fi
|
---|
451 | test -n "${QUICKSETUP}" && return "${mod_succ}"
|
---|
452 | extra_setup
|
---|
453 | if [ "$mod_succ" -eq "0" ]; then
|
---|
454 | if running_vboxguest || running_vboxadd; then
|
---|
455 | begin "You should restart your guest to make sure the new modules are actually used" console
|
---|
456 | fi
|
---|
457 | fi
|
---|
458 | return "${mod_succ}"
|
---|
459 | }
|
---|
460 |
|
---|
461 | # cleanup_script
|
---|
462 | cleanup()
|
---|
463 | {
|
---|
464 | if test -r $config; then
|
---|
465 | . $config
|
---|
466 | test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
|
---|
467 | fail "Configuration file $config not complete"
|
---|
468 | else
|
---|
469 | fail "Configuration file $config not found"
|
---|
470 | fi
|
---|
471 |
|
---|
472 | # Delete old versions of VBox modules.
|
---|
473 | cleanup_modules
|
---|
474 | depmod
|
---|
475 |
|
---|
476 | # Remove old module sources
|
---|
477 | for i in $OLDMODULES; do
|
---|
478 | rm -rf /usr/src/$i-*
|
---|
479 | done
|
---|
480 |
|
---|
481 | # Clean-up X11-related bits
|
---|
482 | /sbin/rcvboxadd-x11 cleanup
|
---|
483 |
|
---|
484 | # Remove other files
|
---|
485 | rm /sbin/mount.vboxsf 2>/dev/null
|
---|
486 | rm /sbin/rcvboxadd 2>/dev/null
|
---|
487 | rm /sbin/rcvboxadd-x11 2>/dev/null
|
---|
488 | rm -f /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
|
---|
489 | rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null
|
---|
490 | rm /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null
|
---|
491 | }
|
---|
492 |
|
---|
493 | dmnstatus()
|
---|
494 | {
|
---|
495 | if running_vboxguest; then
|
---|
496 | echo "The VirtualBox Additions are currently running."
|
---|
497 | else
|
---|
498 | echo "The VirtualBox Additions are not currently running."
|
---|
499 | fi
|
---|
500 | }
|
---|
501 |
|
---|
502 | case "$1" in
|
---|
503 | start)
|
---|
504 | start
|
---|
505 | ;;
|
---|
506 | stop)
|
---|
507 | stop
|
---|
508 | ;;
|
---|
509 | restart)
|
---|
510 | restart
|
---|
511 | ;;
|
---|
512 | setup)
|
---|
513 | setup && start
|
---|
514 | ;;
|
---|
515 | quicksetup)
|
---|
516 | QUICKSETUP=yes
|
---|
517 | setup
|
---|
518 | ;;
|
---|
519 | cleanup)
|
---|
520 | cleanup
|
---|
521 | ;;
|
---|
522 | status)
|
---|
523 | dmnstatus
|
---|
524 | ;;
|
---|
525 | *)
|
---|
526 | echo "Usage: $0 {start|stop|restart|status|setup|quicksetup|cleanup}"
|
---|
527 | exit 1
|
---|
528 | esac
|
---|
529 |
|
---|
530 | exit
|
---|