VirtualBox

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

最後變更 在這個檔案從95890是 95409,由 vboxsync 提交於 3 年 前

Linux host and guest drivers: detect clang, bugref:10247.

Make rcvboxdrv and rcvboxadd to be able to detect if
kernel was build with clang and trigger kernel build
system to compile VBox modules with clang.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette