VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/vboxadd.sh@ 96407

Last change on this file since 96407 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 22.4 KB
Line 
1#! /bin/sh
2# $Id: vboxadd.sh 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# Linux Additions kernel module init script ($Revision: 96407 $)
5#
6
7#
8# Copyright (C) 2006-2022 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# SPDX-License-Identifier: GPL-3.0-only
27#
28
29# X-Start-Before is a Debian Addition which we use when converting to
30# a systemd unit. X-Service-Type is our own invention, also for systemd.
31
32# chkconfig: 345 10 90
33# description: VirtualBox Linux Additions kernel modules
34#
35### BEGIN INIT INFO
36# Provides: vboxadd
37# Required-Start:
38# Required-Stop:
39# Default-Start: 2 3 4 5
40# Default-Stop: 0 1 6
41# X-Start-Before: display-manager
42# X-Service-Type: oneshot
43# Description: VirtualBox Linux Additions kernel modules
44### END INIT INFO
45
46## @todo This file duplicates a lot of script with vboxdrv.sh. When making
47# changes please try to reduce differences between the two wherever possible.
48
49# Testing:
50# * Should fail if the configuration file is missing or missing INSTALL_DIR or
51# INSTALL_VER entries.
52# * vboxadd, vboxsf and vboxdrmipc user groups should be created if they do not exist - test
53# by removing them before installing.
54# * Shared folders can be mounted and auto-mounts accessible to vboxsf group,
55# including on recent Fedoras with SELinux.
56# * Setting INSTALL_NO_MODULE_BUILDS inhibits modules and module automatic
57# rebuild script creation; otherwise modules, user, group, rebuild script,
58# udev rule and shared folder mount helper should be created/set up.
59# * Setting INSTALL_NO_MODULE_BUILDS inhibits module load and unload on start
60# and stop.
61# * Uninstalling the Additions and re-installing them does not trigger warnings.
62
63export LC_ALL=C
64PATH=$PATH:/bin:/sbin:/usr/sbin
65PACKAGE=VBoxGuestAdditions
66MODPROBE=/sbin/modprobe
67OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
68SERVICE="VirtualBox Guest Additions"
69## systemd logs information about service status, otherwise do that ourselves.
70QUIET=
71test -z "${TARGET_VER}" && TARGET_VER=`uname -r`
72# Marker to ignore a particular kernel version which was already installed.
73SKIPFILE_BASE=/var/lib/VBoxGuestAdditions/skip
74export VBOX_KBUILD_TYPE
75export USERNAME
76
77setup_log()
78{
79 test -z "${LOG}" || return 0
80 # Rotate log files
81 LOG="/var/log/vboxadd-setup.log"
82 mv "${LOG}.3" "${LOG}.4" 2>/dev/null
83 mv "${LOG}.2" "${LOG}.3" 2>/dev/null
84 mv "${LOG}.1" "${LOG}.2" 2>/dev/null
85 mv "${LOG}" "${LOG}.1" 2>/dev/null
86}
87
88if $MODPROBE -c 2>/dev/null | grep -q '^allow_unsupported_modules *0'; then
89 MODPROBE="$MODPROBE --allow-unsupported-modules"
90fi
91
92# Preamble for Gentoo
93if [ "`which $0`" = "/sbin/rc" ]; then
94 shift
95fi
96
97begin()
98{
99 test -n "${QUIET}" || echo "${SERVICE}: ${1}"
100}
101
102info()
103{
104 if test -z "${QUIET}"; then
105 echo "${SERVICE}: $1" | fold -s
106 else
107 echo "$1" | fold -s
108 fi
109}
110
111fail()
112{
113 log "${1}"
114 echo "$1" >&2
115 echo "The log file $LOG may contain further information." >&2
116 exit 1
117}
118
119log()
120{
121 setup_log
122 echo "${1}" >> "${LOG}"
123}
124
125module_build_log()
126{
127 log "Error building the module. Build output follows."
128 echo ""
129 echo "${1}" >> "${LOG}"
130}
131
132dev=/dev/vboxguest
133userdev=/dev/vboxuser
134config=/var/lib/VBoxGuestAdditions/config
135owner=vboxadd
136group=1
137
138if test -r $config; then
139 . $config
140else
141 fail "Configuration file $config not found"
142fi
143test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
144 fail "Configuration file $config not complete"
145MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
146BUILDINTMP="$MODULE_SRC/build_in_tmp"
147
148# Attempt to detect VirtualBox Guest Additions version and revision information.
149VBOXCLIENT="${INSTALL_DIR}/bin/VBoxClient"
150VBOX_VERSION="`"$VBOXCLIENT" --version | cut -d r -f1`"
151[ -n "$VBOX_VERSION" ] || VBOX_VERSION='unknown'
152VBOX_REVISION="r`"$VBOXCLIENT" --version | cut -d r -f2`"
153[ "$VBOX_REVISION" != "r" ] || VBOX_REVISION='unknown'
154
155running_vboxguest()
156{
157 lsmod | grep -q "vboxguest[^_-]"
158}
159
160running_vboxadd()
161{
162 lsmod | grep -q "vboxadd[^_-]"
163}
164
165running_vboxsf()
166{
167 lsmod | grep -q "vboxsf[^_-]"
168}
169
170running_vboxvideo()
171{
172 lsmod | grep -q "vboxvideo[^_-]"
173}
174
175do_vboxguest_non_udev()
176{
177 if [ ! -c $dev ]; then
178 maj=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/devices`
179 if [ ! -z "$maj" ]; then
180 min=0
181 else
182 min=`sed -n 's;\([0-9]\+\) vboxguest;\1;p' /proc/misc`
183 if [ ! -z "$min" ]; then
184 maj=10
185 fi
186 fi
187 test -n "$maj" || {
188 rmmod vboxguest 2>/dev/null
189 fail "Cannot locate the VirtualBox device"
190 }
191
192 mknod -m 0664 $dev c $maj $min || {
193 rmmod vboxguest 2>/dev/null
194 fail "Cannot create device $dev with major $maj and minor $min"
195 }
196 fi
197 chown $owner:$group $dev 2>/dev/null || {
198 rm -f $dev 2>/dev/null
199 rm -f $userdev 2>/dev/null
200 rmmod vboxguest 2>/dev/null
201 fail "Cannot change owner $owner:$group for device $dev"
202 }
203
204 if [ ! -c $userdev ]; then
205 maj=10
206 min=`sed -n 's;\([0-9]\+\) vboxuser;\1;p' /proc/misc`
207 if [ ! -z "$min" ]; then
208 mknod -m 0666 $userdev c $maj $min || {
209 rm -f $dev 2>/dev/null
210 rmmod vboxguest 2>/dev/null
211 fail "Cannot create device $userdev with major $maj and minor $min"
212 }
213 chown $owner:$group $userdev 2>/dev/null || {
214 rm -f $dev 2>/dev/null
215 rm -f $userdev 2>/dev/null
216 rmmod vboxguest 2>/dev/null
217 fail "Cannot change owner $owner:$group for device $userdev"
218 }
219 fi
220 fi
221}
222
223restart()
224{
225 stop && start
226 return 0
227}
228
229## Update the initramfs. Debian and Ubuntu put the graphics driver in, and
230# need the touch(1) command below. Everyone else that I checked just need
231# the right module alias file from depmod(1) and only use the initramfs to
232# load the root filesystem, not the boot splash. update-initramfs works
233# for the first two and dracut for every one else I checked. We are only
234# interested in distributions recent enough to use the KMS vboxvideo driver.
235update_initramfs()
236{
237 ## kernel version to update for.
238 version="${1}"
239 depmod "${version}"
240 rm -f "/lib/modules/${version}/initrd/vboxvideo"
241 test ! -d "/lib/modules/${version}/initrd" ||
242 test ! -f "/lib/modules/${version}/misc/vboxvideo.ko" ||
243 touch "/lib/modules/${version}/initrd/vboxvideo"
244
245 # Systems without systemd-inhibit probably don't need their initramfs
246 # rebuild here anyway.
247 type systemd-inhibit >/dev/null 2>&1 || return
248 if type dracut >/dev/null 2>&1; then
249 systemd-inhibit --why="Installing VirtualBox Guest Additions" \
250 dracut -f --kver "${version}"
251 elif type update-initramfs >/dev/null 2>&1; then
252 systemd-inhibit --why="Installing VirtualBox Guest Additions" \
253 update-initramfs -u -k "${version}"
254 fi
255}
256
257# Remove any existing VirtualBox guest kernel modules from the disk, but not
258# from the kernel as they may still be in use
259cleanup_modules()
260{
261 # Needed for Ubuntu and Debian, see update_initramfs
262 rm -f /lib/modules/*/initrd/vboxvideo
263 for i in /lib/modules/*/misc; do
264 KERN_VER="${i%/misc}"
265 KERN_VER="${KERN_VER#/lib/modules/}"
266 unset do_update
267 for j in ${OLDMODULES}; do
268 test -f "${i}/${j}.ko" && do_update=1 && rm -f "${i}/${j}.ko"
269 done
270 test -z "$do_update" || update_initramfs "$KERN_VER"
271 # Remove empty /lib/modules folders which may have been kept around
272 rmdir -p "${i}" 2>/dev/null || true
273 unset keep
274 for j in /lib/modules/"${KERN_VER}"/*; do
275 name="${j##*/}"
276 test -d "${name}" || test "${name%%.*}" != modules && keep=1
277 done
278 if test -z "${keep}"; then
279 rm -rf /lib/modules/"${KERN_VER}"
280 rm -f /boot/initrd.img-"${KERN_VER}"
281 fi
282 done
283 for i in ${OLDMODULES}; do
284 # We no longer support DKMS, remove any leftovers.
285 rm -rf "/var/lib/dkms/${i}"*
286 done
287 rm -f /etc/depmod.d/vboxvideo-upstream.conf
288 rm -f "$SKIPFILE_BASE"-*
289}
290
291# Build and install the VirtualBox guest kernel modules
292setup_modules()
293{
294 KERN_VER="$1"
295 test -n "$KERN_VER" || return 1
296 # Match (at least): vboxguest.o; vboxguest.ko; vboxguest.ko.xz
297 set /lib/modules/"$KERN_VER"/misc/vboxguest.*o*
298 test ! -f "$1" || return 0
299 test -d /lib/modules/"$KERN_VER"/build || return 0
300 export KERN_VER
301 info "Building the modules for kernel $KERN_VER."
302
303 # Detect if kernel was built with clang.
304 unset LLVM
305 vbox_cc_is_clang=$(/lib/modules/"$KERN_VER"/build/scripts/config \
306 --file /lib/modules/"$KERN_VER"/build/.config \
307 --state CONFIG_CC_IS_CLANG 2>/dev/null)
308 if test "${vbox_cc_is_clang}" = "y"; then
309 info "Using clang compiler."
310 export LLVM=1
311 fi
312
313 log "Building the main Guest Additions $INSTALL_VER module for kernel $KERN_VER."
314 if ! myerr=`$BUILDINTMP \
315 --save-module-symvers /tmp/vboxguest-Module.symvers \
316 --module-source $MODULE_SRC/vboxguest \
317 --no-print-directory install 2>&1`; then
318 # If check_module_dependencies.sh fails it prints a message itself.
319 module_build_log "$myerr"
320 "${INSTALL_DIR}"/other/check_module_dependencies.sh 2>&1 &&
321 info "Look at $LOG to find out what went wrong"
322 return 0
323 fi
324 log "Building the shared folder support module."
325 if ! myerr=`$BUILDINTMP \
326 --use-module-symvers /tmp/vboxguest-Module.symvers \
327 --module-source $MODULE_SRC/vboxsf \
328 --no-print-directory install 2>&1`; then
329 module_build_log "$myerr"
330 info "Look at $LOG to find out what went wrong"
331 return 0
332 fi
333 log "Building the graphics driver module."
334 if ! myerr=`$BUILDINTMP \
335 --use-module-symvers /tmp/vboxguest-Module.symvers \
336 --module-source $MODULE_SRC/vboxvideo \
337 --no-print-directory install 2>&1`; then
338 module_build_log "$myerr"
339 info "Look at $LOG to find out what went wrong"
340 fi
341 [ -d /etc/depmod.d ] || mkdir /etc/depmod.d
342 echo "override vboxguest * misc" > /etc/depmod.d/vboxvideo-upstream.conf
343 echo "override vboxsf * misc" >> /etc/depmod.d/vboxvideo-upstream.conf
344 echo "override vboxvideo * misc" >> /etc/depmod.d/vboxvideo-upstream.conf
345 update_initramfs "${KERN_VER}"
346 return 0
347}
348
349create_vbox_user()
350{
351 # This is the LSB version of useradd and should work on recent
352 # distributions
353 useradd -d /var/run/vboxadd -g 1 -r -s /bin/false vboxadd >/dev/null 2>&1 || true
354 # And for the others, we choose a UID ourselves
355 useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1 || true
356
357}
358
359create_udev_rule()
360{
361 # Create udev description file
362 if [ -d /etc/udev/rules.d ]; then
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 # Make sure the new rule is noticed.
385 udevadm control --reload >/dev/null 2>&1 || true
386 udevcontrol reload_rules >/dev/null 2>&1 || true
387 fi
388}
389
390create_module_rebuild_script()
391{
392 # And a post-installation script for rebuilding modules when a new kernel
393 # is installed.
394 mkdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d
395 cat << EOF > /etc/kernel/postinst.d/vboxadd
396#!/bin/sh
397# This only works correctly on Debian derivatives - Red Hat calls it before
398# installing the right header files.
399/sbin/rcvboxadd quicksetup "\${1}"
400exit 0
401EOF
402 cat << EOF > /etc/kernel/prerm.d/vboxadd
403#!/bin/sh
404for i in ${OLDMODULES}; do rm -f /lib/modules/"\${1}"/misc/"\${i}".ko; done
405rmdir -p /lib/modules/"\$1"/misc 2>/dev/null || true
406exit 0
407EOF
408 chmod 0755 /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
409}
410
411shared_folder_setup()
412{
413 # Add a group "vboxsf" for Shared Folders access
414 # All users which want to access the auto-mounted Shared Folders have to
415 # be added to this group.
416 groupadd -r -f vboxsf >/dev/null 2>&1
417
418 # Put the mount.vboxsf mount helper in the right place.
419 ## @todo It would be nicer if the kernel module just parsed parameters
420 # itself instead of needing a separate binary to do that.
421 ln -sf "${INSTALL_DIR}/other/mount.vboxsf" /sbin
422 # SELinux security context for the mount helper.
423 if test -e /etc/selinux/config; then
424 # This is correct. semanage maps this to the real path, and it aborts
425 # with an error, telling you what you should have typed, if you specify
426 # the real path. The "chcon" is there as a back-up for old guests.
427 command -v semanage > /dev/null &&
428 semanage fcontext -a -t mount_exec_t "${INSTALL_DIR}/other/mount.vboxsf"
429 chcon -t mount_exec_t "${INSTALL_DIR}/other/mount.vboxsf" 2>/dev/null
430 fi
431}
432
433# Returns path to module file as seen by modinfo(8) or empty string.
434module_path()
435{
436 mod="$1"
437 [ -n "$mod" ] || return
438
439 modinfo "$mod" 2>/dev/null | grep -e "^filename:" | tr -s ' ' | cut -d " " -f2
440}
441
442# Returns module version if module is available or empty string.
443module_version()
444{
445 mod="$1"
446 [ -n "$mod" ] || return
447
448 modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f2
449}
450
451# Returns module revision if module is available in the system or empty string.
452module_revision()
453{
454 mod="$1"
455 [ -n "$mod" ] || return
456
457 modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f3
458}
459
460# Returns "1" if externally built module is available in the system and its
461# version and revision number do match to current VirtualBox installation.
462# Or empty string otherwise.
463module_available()
464{
465 mod="$1"
466 [ -n "$mod" ] || return
467
468 [ "$VBOX_VERSION" = "$(module_version "$mod")" ] || return
469 [ "$VBOX_REVISION" = "$(module_revision "$mod")" ] || return
470
471 # Check if module belongs to VirtualBox installation.
472 #
473 # We have a convention that only modules from /lib/modules/*/misc
474 # belong to us. Modules from other locations are treated as
475 # externally built.
476 mod_path="$(module_path "$mod")"
477
478 # If module path points to a symbolic link, resolve actual file location.
479 [ -L "$mod_path" ] && mod_path="$(readlink -e -- "$mod_path")"
480
481 # File exists?
482 [ -f "$mod_path" ] || return
483
484 # Extract last component of module path and check whether it is located
485 # outside of /lib/modules/*/misc.
486 mod_dir="$(dirname "$mod_path" | sed 's;^.*/;;')"
487 [ "$mod_dir" = "misc" ] || return
488
489 echo "1"
490}
491
492# Check if required modules are installed in the system and versions match.
493setup_complete()
494{
495 [ "$(module_available vboxguest)" = "1" ] || return
496 [ "$(module_available vboxsf)" = "1" ] || return
497
498 # All modules are in place.
499 echo "1"
500}
501
502# setup_script
503setup()
504{
505 # chcon is needed on old Fedora/Redhat systems. No one remembers which.
506 test ! -e /etc/selinux/config ||
507 chcon -t bin_t "$BUILDINTMP" 2>/dev/null
508
509 if test -z "$INSTALL_NO_MODULE_BUILDS"; then
510 # Check whether modules setup is already complete for currently running kernel.
511 # Prevent unnecessary rebuilding in order to speed up booting process.
512 if test "$(setup_complete)" = "1"; then
513 info "VirtualBox Guest Additions kernel modules $VBOX_VERSION $VBOX_REVISION are"
514 info "already available for kernel $TARGET_VER and do not require to be rebuilt."
515 else
516 info "Building the VirtualBox Guest Additions kernel modules. This may take a while."
517 info "To build modules for other installed kernels, run"
518 info " /sbin/rcvboxadd quicksetup <version>"
519 info "or"
520 info " /sbin/rcvboxadd quicksetup all"
521 if test -d /lib/modules/"$TARGET_VER"/build; then
522 setup_modules "$TARGET_VER"
523 depmod
524 else
525 info "Kernel headers not found for target kernel $TARGET_VER. \
526Please install them and execute
527 /sbin/rcvboxadd setup"
528 fi
529 fi
530 fi
531 create_vbox_user
532 create_udev_rule
533 test -n "${INSTALL_NO_MODULE_BUILDS}" || create_module_rebuild_script
534 shared_folder_setup
535 # Create user group which will have permissive access to DRP IPC server socket.
536 groupadd -r -f vboxdrmipc >/dev/null 2>&1
537
538 if running_vboxguest || running_vboxadd; then
539 info "Running kernel modules will not be replaced until the system is restarted"
540 fi
541
542 # Put the X.Org driver in place. This is harmless if it is not needed.
543 # Also set up the OpenGL library.
544 myerr=`"${INSTALL_DIR}/init/vboxadd-x11" setup 2>&1`
545 test -z "${myerr}" || log "${myerr}"
546
547 return 0
548}
549
550# cleanup_script
551cleanup()
552{
553 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
554 # Delete old versions of VBox modules.
555 cleanup_modules
556 depmod
557
558 # Remove old module sources
559 for i in $OLDMODULES; do
560 rm -rf /usr/src/$i-*
561 done
562 fi
563
564 # Clean-up X11-related bits
565 "${INSTALL_DIR}/init/vboxadd-x11" cleanup
566
567 # Remove other files
568 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
569 rm -f /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
570 rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null || true
571 fi
572 rm -f /sbin/mount.vboxsf 2>/dev/null
573 rm -f /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null
574 udevadm control --reload >/dev/null 2>&1 || true
575 udevcontrol reload_rules >/dev/null 2>&1 || true
576}
577
578start()
579{
580 begin "Starting."
581 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
582 # We want to build modules for newly installed kernels on shutdown, so
583 # mark the ones already present. These will be ignored on shutdown.
584 rm -f "$SKIPFILE_BASE"-*
585 for setupi in /lib/modules/*; do
586 KERN_VER="${setupi##*/}"
587 # For a full setup, mark kernels we do not want to build.
588 touch "$SKIPFILE_BASE"-"$KERN_VER"
589 done
590 fi
591 setup
592 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
593 test -d /sys &&
594 ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
595 no_udev=1
596 running_vboxguest || {
597 rm -f $dev || {
598 fail "Cannot remove $dev"
599 }
600 rm -f $userdev || {
601 fail "Cannot remove $userdev"
602 }
603 $MODPROBE vboxguest >/dev/null 2>&1 ||
604 fail "modprobe vboxguest failed"
605 case "$no_udev" in 1)
606 sleep .5;;
607 esac
608 $MODPROBE vboxsf > /dev/null 2>&1 ||
609 info "modprobe vboxsf failed"
610 }
611 case "$no_udev" in 1)
612 do_vboxguest_non_udev;;
613 esac
614 fi # INSTALL_NO_MODULE_BUILDS
615
616 return 0
617}
618
619stop()
620{
621 begin "Stopping."
622 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
623 # We want to build modules for newly installed kernels on shutdown, so
624 # check which we marked at start-up.
625 for setupi in /lib/modules/*; do
626 KERN_VER="${setupi##*/}"
627 # For a full setup, mark kernels we do not want to build.
628 test -f "$SKIPFILE_BASE"-"$KERN_VER" || setup_modules "$KERN_VER"
629 done
630 fi
631 if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then
632 rm /etc/ld.so.conf.d/00vboxvideo.conf
633 ldconfig
634 fi
635 if ! umount -a -t vboxsf 2>/dev/null; then
636 # Make sure we only fail, if there are truly no more vboxsf
637 # mounts in the system.
638 [ -n "$(findmnt -t vboxsf)" ] && fail "Cannot unmount vboxsf folders"
639 fi
640 test -n "${INSTALL_NO_MODULE_BUILDS}" ||
641 info "You may need to restart your guest system to finish removing guest drivers."
642 return 0
643}
644
645dmnstatus()
646{
647 if running_vboxguest; then
648 echo "The VirtualBox Additions are currently running."
649 else
650 echo "The VirtualBox Additions are not currently running."
651 fi
652}
653
654for i; do
655 case "$i" in quiet) QUIET=yes;; esac
656done
657case "$1" in
658# Does setup without clean-up first and marks all kernels currently found on the
659# system so that we can see later if any were added.
660start)
661 start
662 ;;
663# Tries to build kernel modules for kernels added since start. Tries to unmount
664# shared folders. Uninstalls our Chromium 3D libraries since we can't always do
665# this fast enough at start time if we discover we do not want to use them.
666stop)
667 stop
668 ;;
669restart)
670 restart
671 ;;
672# Setup does a clean-up (see below) and re-does all Additions-specific
673# configuration of the guest system, including building kernel modules for the
674# current kernel.
675setup)
676 cleanup && start
677 ;;
678# Builds kernel modules for the specified kernels if they are not already built.
679quicksetup)
680 if test x"$2" = xall; then
681 for topi in /lib/modules/*; do
682 KERN_VER="${topi%/misc}"
683 KERN_VER="${KERN_VER#/lib/modules/}"
684 setup_modules "$KERN_VER"
685 done
686 elif test -n "$2"; then
687 setup_modules "$2"
688 else
689 setup_modules "$TARGET_VER"
690 fi
691 ;;
692# Clean-up removes all Additions-specific configuration of the guest system,
693# including all kernel modules.
694cleanup)
695 cleanup
696 ;;
697status)
698 dmnstatus
699 ;;
700*)
701 echo "Usage: $0 {start|stop|restart|status|setup|quicksetup|cleanup} [quiet]"
702 exit 1
703esac
704
705exit
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use