1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Oracle VirtualBox
|
---|
4 | # VirtualBox Makeself installation starter script
|
---|
5 | # for Linux Guest Additions
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2024 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 | # Testing:
|
---|
30 | # * After successful installation, 0 is returned if the vboxguest module version
|
---|
31 | # built matches the one loaded and 2 is returned otherwise. E.g. VBoxClient
|
---|
32 | # running will prevent vboxguest reloading.
|
---|
33 | # * If the kernel modules cannot be built (run the installer with KERN_VER=none)
|
---|
34 | # or loaded (run with KERN_VER=<installed non-current version>) then 1 is
|
---|
35 | # returned.
|
---|
36 |
|
---|
37 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
38 |
|
---|
39 | # Note: These variable names must *not* clash with variables in $CONFIG_DIR/$CONFIG!
|
---|
40 | PACKAGE="VBoxGuestAdditions"
|
---|
41 | PACKAGE_NAME="VirtualBox Guest Additions"
|
---|
42 | UNINSTALL="uninstall.sh"
|
---|
43 | PUBLIC_UNINSTALL_HOOK="/usr/sbin/vbox-uninstall-guest-additions"
|
---|
44 | ROUTINES="routines.sh"
|
---|
45 | INSTALLATION_VER="_VERSION_"
|
---|
46 | BUILD_VBOX_KBUILD_TYPE="_BUILDTYPE_"
|
---|
47 | BUILD_USERNAME="_USERNAME_"
|
---|
48 | UNINSTALL_SCRIPTS="vboxadd-x11 vboxvfs vboxadd-timesync vboxadd-service vboxadd"
|
---|
49 |
|
---|
50 | INSTALLATION_DIR="/opt/$PACKAGE-$INSTALLATION_VER"
|
---|
51 | CONFIG_DIR="/var/lib/$PACKAGE"
|
---|
52 | CONFIG="config"
|
---|
53 | CONFIG_FILES="filelist"
|
---|
54 | SELF=$1
|
---|
55 | LOGFILE="/var/log/vboxadd-install.log"
|
---|
56 |
|
---|
57 | ## Were we able to stop any previously running Additions kernel modules?
|
---|
58 | MODULES_STOPPED=1
|
---|
59 |
|
---|
60 | . "./$ROUTINES"
|
---|
61 |
|
---|
62 | check_root
|
---|
63 |
|
---|
64 | check_deps bzip2 tar
|
---|
65 |
|
---|
66 | create_log "$LOGFILE"
|
---|
67 |
|
---|
68 | usage()
|
---|
69 | {
|
---|
70 | catinfo << EOF
|
---|
71 |
|
---|
72 | Usage: $SELF install [<installation directory>]
|
---|
73 | [--with-<module>]
|
---|
74 | [--package-base <base> |
|
---|
75 | uninstall
|
---|
76 | [--force] [--no-setup]
|
---|
77 |
|
---|
78 | Options:
|
---|
79 | --package-base <base> For use when building distribution packages.
|
---|
80 | Installs relative to <base> instead of to "/",
|
---|
81 | does not run setup, installs to "<base>/usr/lib"
|
---|
82 | instead of to "/opt" and does not create uninstall.
|
---|
83 | --force Forces an upgrade. Not recommended.
|
---|
84 |
|
---|
85 | Example:
|
---|
86 | $SELF install
|
---|
87 | EOF
|
---|
88 | exit 1
|
---|
89 | }
|
---|
90 |
|
---|
91 | # Create a symlink in the filesystem and add it to the list of package files
|
---|
92 | add_symlink()
|
---|
93 | {
|
---|
94 | self=add_symlink
|
---|
95 | ## Parameters:
|
---|
96 | # The file the link should point to
|
---|
97 | target="$1"
|
---|
98 | # The name of the actual symlink file. Must be an absolute path to a
|
---|
99 | # non-existing file in an existing directory.
|
---|
100 | link="$2"
|
---|
101 | link_dir="`dirname "$link"`"
|
---|
102 | test -n "$target" ||
|
---|
103 | { echo 1>&2 "$self: no target specified"; return 1; }
|
---|
104 | test -d "$link_dir" ||
|
---|
105 | { echo 1>&2 "$self: link directory $link_dir does not exist"; return 1; }
|
---|
106 | expr "$link" : "/.*" > /dev/null ||
|
---|
107 | { echo 1>&2 "$self: link file name is not absolute"; return 1; }
|
---|
108 | rm -f "$link"
|
---|
109 | ln -s "$target" "$link"
|
---|
110 | echo "$link" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
111 | }
|
---|
112 |
|
---|
113 | # Create symbolic links targeting all files in a directory in another
|
---|
114 | # directory in the filesystem
|
---|
115 | link_into_fs()
|
---|
116 | {
|
---|
117 | ## Parameters:
|
---|
118 | # Directory containing the link target files
|
---|
119 | target_branch="$1"
|
---|
120 | # Directory to create the link files in
|
---|
121 | directory="$2"
|
---|
122 | for i in "$INSTALLATION_DIR/$target_branch"/*; do
|
---|
123 | test -e "$i" &&
|
---|
124 | add_symlink "$i" "$directory/`basename $i`"
|
---|
125 | done
|
---|
126 | }
|
---|
127 |
|
---|
128 | # Look for broken installations or installations without a known uninstaller
|
---|
129 | # and try to clean them up, asking the user first.
|
---|
130 | def_uninstall()
|
---|
131 | {
|
---|
132 | ## Parameters:
|
---|
133 | # Whether to force cleanup without asking the user
|
---|
134 | force="$1"
|
---|
135 |
|
---|
136 | . ./deffiles
|
---|
137 | found=0
|
---|
138 | for i in "/opt/$PACKAGE-"*; do
|
---|
139 | test -e "$i" && found=1
|
---|
140 | done
|
---|
141 | for i in $DEFAULT_FILE_NAMES; do
|
---|
142 | test "$found" = 0 && test -e "$i" && found=1
|
---|
143 | done
|
---|
144 | test "$found" = 0 &&
|
---|
145 | for i in $DEFAULT_VERSIONED_FILE_NAMES; do
|
---|
146 | for j in $i-*; do
|
---|
147 | test "$found" = 0 && test -e "$j" && found=1
|
---|
148 | done
|
---|
149 | done
|
---|
150 | test "$found" = 0 && return 0
|
---|
151 | if ! test "$1" = "force" ; then
|
---|
152 | # Try to make the promised notification appear on next start.
|
---|
153 | VBoxControl guestproperty delete \
|
---|
154 | /VirtualBox/GuestAdd/HostVerLastChecked 2>&1 > /dev/null
|
---|
155 | cat 1>&2 << EOF
|
---|
156 | This system appears to have a version of the VirtualBox Guest Additions
|
---|
157 | already installed. If it is part of the operating system and kept up-to-date,
|
---|
158 | there is most likely no need to replace it. If it is not up-to-date, you
|
---|
159 | should get a notification when you start the system. If you wish to replace
|
---|
160 | it with this version, please do not continue with this installation now, but
|
---|
161 | instead remove the current version first, following the instructions for the
|
---|
162 | operating system.
|
---|
163 |
|
---|
164 | If your system simply has the remains of a version of the Additions you could
|
---|
165 | not remove you should probably continue now, and these will be removed during
|
---|
166 | installation.
|
---|
167 |
|
---|
168 | Do you wish to continue? [yes or no]
|
---|
169 | EOF
|
---|
170 | read reply dummy
|
---|
171 | if ! expr "$reply" : [yY] > /dev/null &&
|
---|
172 | ! expr "$reply" : [yY][eE][sS] > /dev/null
|
---|
173 | then
|
---|
174 | info
|
---|
175 | info "Cancelling installation."
|
---|
176 | return 1
|
---|
177 | fi
|
---|
178 | fi
|
---|
179 | # Inhibit rebuilding of any installed kernels.
|
---|
180 | for i in /lib/modules/*; do
|
---|
181 | ver="${i##*/}"
|
---|
182 | test ! -d "$i"/build || touch /var/lib/VBoxGuestAdditions/skip-"$ver"
|
---|
183 | done
|
---|
184 | # Stop what we can in the way of services and remove them from the
|
---|
185 | # system
|
---|
186 | for i in $UNINSTALL_SCRIPTS; do
|
---|
187 | stop_init_script "$i" 2>> "${LOGFILE}"
|
---|
188 | test -z "$NO_CLEANUP" && test -x "./$i" && "./$i" cleanup 1>&2 2>> "$LOGFILE"
|
---|
189 | delrunlevel "$i" 2>> "${LOGFILE}"
|
---|
190 | remove_init_script "$i" 2>> "${LOGFILE}"
|
---|
191 | done
|
---|
192 | for i in "/opt/$PACKAGE-"*/init; do
|
---|
193 | for j in $UNINSTALL_SCRIPTS; do
|
---|
194 | script="${i}/${j}"
|
---|
195 | test -x "${script}" && test -z "$NO_CLEANUP" &&
|
---|
196 | grep -q '^# *cleanup_script *$' "${script}" &&
|
---|
197 | "${script}" cleanup 1>&2 2>> "$LOGFILE"
|
---|
198 | done
|
---|
199 | done
|
---|
200 |
|
---|
201 | # Get rid of any remaining files
|
---|
202 | for i in $DEFAULT_FILE_NAMES; do
|
---|
203 | rm -f "$i" 2> /dev/null
|
---|
204 | done
|
---|
205 | for i in $DEFAULT_VERSIONED_FILE_NAMES; do
|
---|
206 | rm -f "$i-"* 2> /dev/null
|
---|
207 | done
|
---|
208 | rm -f "/usr/lib/$PACKAGE" "/usr/lib64/$PACKAGE" "/usr/share/$PACKAGE" \
|
---|
209 | "/usr/lib/i386-linux-gnu/$PACKAGE" "/usr/lib/x86_64-linux-gnu/$PACKAGE"
|
---|
210 |
|
---|
211 | # And any packages left under /opt
|
---|
212 | for i in "/opt/$PACKAGE-"*; do
|
---|
213 | test -d "$i" && rm -rf "$i"
|
---|
214 | done
|
---|
215 | return 0
|
---|
216 | }
|
---|
217 |
|
---|
218 | info "$PACKAGE_NAME installer"
|
---|
219 |
|
---|
220 | # Sensible default actions
|
---|
221 | ACTION="install"
|
---|
222 | NO_CLEANUP=""
|
---|
223 | FORCE_UPGRADE=""
|
---|
224 | PACKAGE_BASE=""
|
---|
225 |
|
---|
226 | while [ $# -ge 2 ];
|
---|
227 | do
|
---|
228 | ARG=$2
|
---|
229 | shift
|
---|
230 |
|
---|
231 | if [ -z "$MY_END_OF_OPTIONS" ]; then
|
---|
232 | case "$ARG" in
|
---|
233 |
|
---|
234 | install)
|
---|
235 | ACTION="install"
|
---|
236 | ;;
|
---|
237 |
|
---|
238 | uninstall)
|
---|
239 | ACTION="uninstall"
|
---|
240 | ;;
|
---|
241 |
|
---|
242 | package)
|
---|
243 | ACTION="package"
|
---|
244 | INSTALLATION_DIR=/usr/lib
|
---|
245 | PACKAGE_BASE="$2"
|
---|
246 | shift
|
---|
247 | if test ! -d "${PACKAGE_BASE}"; then
|
---|
248 | info "Package base directory not found."
|
---|
249 | usage
|
---|
250 | fi
|
---|
251 | ;;
|
---|
252 |
|
---|
253 | ## @todo Add per-module options handling, e.g. --lightdm-greeter-dir
|
---|
254 | # or --lightdm-config
|
---|
255 |
|
---|
256 | ## @todo Add listing all available modules (+ their options, e.g.
|
---|
257 | # with callback mod_mymod_show_options?)
|
---|
258 |
|
---|
259 | --with-*)
|
---|
260 | MODULE_CUR=`expr "$ARG" : '--with-\(.*\)'`
|
---|
261 | # Check if corresponding module in installer/module-$1 exists.
|
---|
262 | # Note: Module names may not contain spaces or other funny things.
|
---|
263 | if [ ! -f "./installer/module-${MODULE_CUR}" ]; then
|
---|
264 | info "Error: Module \"${MODULE_CUR}\" does not exist."
|
---|
265 | usage
|
---|
266 | fi
|
---|
267 | # Give the module the chance of doing initialization work / checks.
|
---|
268 | . "./installer/module-${MODULE_CUR}"
|
---|
269 | mod_${MODULE_CUR}_init
|
---|
270 | if test $? -ne 0; then
|
---|
271 | echo 1>&2 "Module '${MODULE_CUR}' failed to initialize"
|
---|
272 | if ! test "$FORCE_UPGRADE" = "force"; then
|
---|
273 | return 1
|
---|
274 | fi
|
---|
275 | # Continue initialization.
|
---|
276 | fi
|
---|
277 | # Add module to the list of modules to handle later.
|
---|
278 | if test -z "${INSTALLATION_MODULES_LIST}"; then
|
---|
279 | INSTALLATION_MODULES_LIST="${MODULE_CUR}"
|
---|
280 | else
|
---|
281 | INSTALLATION_MODULES_LIST="${INSTALLATION_MODULES_LIST} ${MODULE_CUR}"
|
---|
282 | fi
|
---|
283 | shift
|
---|
284 | ;;
|
---|
285 |
|
---|
286 | --force|force) # Keep "force" for backwards compatibility.
|
---|
287 | FORCE_UPGRADE="force"
|
---|
288 | ;;
|
---|
289 |
|
---|
290 | --no-setup|no_setup)
|
---|
291 | # Deprecated; keep this setting for backwards compatibility.
|
---|
292 | ;;
|
---|
293 |
|
---|
294 | --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
|
---|
295 | # Do not do cleanup of old modules when removing them. For
|
---|
296 | # testing purposes only.
|
---|
297 | NO_CLEANUP="no_cleanup"
|
---|
298 | ;;
|
---|
299 |
|
---|
300 | --)
|
---|
301 | MY_END_OF_OPTIONS="1"
|
---|
302 | ;;
|
---|
303 |
|
---|
304 | *)
|
---|
305 | if [ "`echo $1|cut -c1`" != "/" ]; then
|
---|
306 | info "Please specify an absolute path"
|
---|
307 | usage
|
---|
308 | fi
|
---|
309 | INSTALLATION_DIR="$1"
|
---|
310 | shift
|
---|
311 | ;;
|
---|
312 | esac
|
---|
313 | fi
|
---|
314 | done
|
---|
315 |
|
---|
316 | # Check architecture
|
---|
317 | cpu=`uname -m`;
|
---|
318 | case "$cpu" in
|
---|
319 | i[3456789]86|x86)
|
---|
320 | cpu="x86"
|
---|
321 | lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"
|
---|
322 | ;;
|
---|
323 | x86_64|amd64)
|
---|
324 | cpu="amd64"
|
---|
325 | lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"
|
---|
326 | ;;
|
---|
327 | aarch64|arm64)
|
---|
328 | cpu="arm64"
|
---|
329 | lib_candidates="/usr/lib64 /usr/lib /lib64 /lib"
|
---|
330 | ;;
|
---|
331 | *)
|
---|
332 | cpu="unknown"
|
---|
333 | esac
|
---|
334 | ARCH_PACKAGE="$PACKAGE-$cpu.tar.bz2"
|
---|
335 | if [ ! -r "$ARCH_PACKAGE" ]; then
|
---|
336 | info "Detected unsupported $cpu machine type."
|
---|
337 | exit 1
|
---|
338 | fi
|
---|
339 | # Find the most appropriate libary folder by seeing which of the candidate paths
|
---|
340 | # are actually in the shared linker path list and choosing the first. We look
|
---|
341 | # for Debian-specific paths first, then LSB ones, then the new RedHat ones.
|
---|
342 | libs=`ldconfig -v 2>/dev/null | grep -v ^$'\t'`
|
---|
343 | for i in $lib_candidates; do
|
---|
344 | if echo $libs | grep -q $i; then
|
---|
345 | lib_path=$i
|
---|
346 | break
|
---|
347 | fi
|
---|
348 | done
|
---|
349 | if [ ! -x "$lib_path" ]; then
|
---|
350 | info "Unable to determine correct library path."
|
---|
351 | exit 1
|
---|
352 | fi
|
---|
353 |
|
---|
354 | # uninstall any previous installation
|
---|
355 | # If the currently installed Additions have provided an uninstallation hook, try
|
---|
356 | # that first.
|
---|
357 | if test -x "${PUBLIC_UNINSTALL_HOOK}"; then
|
---|
358 | "${PUBLIC_UNINSTALL_HOOK}" 1>&2 ||
|
---|
359 | abort "Failed to remove existing installation. Aborting..."
|
---|
360 | fi
|
---|
361 |
|
---|
362 | INSTALL_DIR=""
|
---|
363 | uninstalled=0
|
---|
364 | test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
|
---|
365 | if test -n "$INSTALL_DIR" && test -n "$UNINSTALLER" &&
|
---|
366 | test -x "$INSTALL_DIR/$UNINSTALLER"; then
|
---|
367 | "$INSTALL_DIR/$UNINSTALLER" $NO_CLEANUP 1>&2 ||
|
---|
368 | abort "Failed to remove existing installation. Aborting..."
|
---|
369 | uninstalled=1
|
---|
370 | fi
|
---|
371 | test "$uninstalled" = 0 && def_uninstall "$FORCE_UPGRADE" && uninstalled=1
|
---|
372 | test "$uninstalled" = 0 && exit 1
|
---|
373 | rm -f "$CONFIG_DIR/$CONFIG"
|
---|
374 | rm -f "$CONFIG_DIR/$CONFIG_FILES"
|
---|
375 | rmdir "$CONFIG_DIR" 2>/dev/null || true
|
---|
376 | test "$ACTION" = "install" || exit 0
|
---|
377 |
|
---|
378 | # Now check whether the kernel modules were stopped.
|
---|
379 | lsmod | grep -q vboxguest && MODULES_STOPPED=
|
---|
380 |
|
---|
381 | # Choose a proper umask
|
---|
382 | umask 022
|
---|
383 |
|
---|
384 | # Set installer modules directory
|
---|
385 | INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
|
---|
386 |
|
---|
387 | # install the new version
|
---|
388 | mkdir -p -m 755 "$CONFIG_DIR"
|
---|
389 | test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
|
---|
390 | mkdir -p -m 755 "$INSTALLATION_DIR"
|
---|
391 |
|
---|
392 | # install and load installer modules
|
---|
393 | if [ -d installer ]; then
|
---|
394 | info "Copying additional installer modules ..."
|
---|
395 | mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
|
---|
396 | for CUR_FILE in `ls installer/*`; do
|
---|
397 | install -p -m 755 "$CUR_FILE" "$INSTALLATION_MODULES_DIR"
|
---|
398 | if [ $? -ne 0 ]; then
|
---|
399 | info "Error: Failed to copy installer module \"$CUR_FILE\""
|
---|
400 | if ! test "$FORCE_UPGRADE" = "force"; then
|
---|
401 | exit 1
|
---|
402 | fi
|
---|
403 | fi
|
---|
404 | done
|
---|
405 | fi
|
---|
406 |
|
---|
407 | # Create a list of the files in the archive, skipping any directories which
|
---|
408 | # already exist in the filesystem.
|
---|
409 | bzip2 -d -c "$ARCH_PACKAGE" | tar -tf - |
|
---|
410 | while read name; do
|
---|
411 | fullname="$INSTALLATION_DIR/$name"
|
---|
412 | case "$fullname" in
|
---|
413 | */)
|
---|
414 | test ! -d "$fullname" &&
|
---|
415 | echo "$fullname" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
416 | ;;
|
---|
417 | *)
|
---|
418 | echo "$fullname" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
419 | ;;
|
---|
420 | esac
|
---|
421 | done
|
---|
422 | bzip2 -d -c "$ARCH_PACKAGE" | tar -xf - -C "$INSTALLATION_DIR" || exit 1
|
---|
423 |
|
---|
424 | # Set symlinks into /usr and /sbin
|
---|
425 | link_into_fs "bin" "${PACKAGE_BASE}/usr/bin"
|
---|
426 | link_into_fs "sbin" "${PACKAGE_BASE}/usr/sbin"
|
---|
427 | link_into_fs "lib" "$lib_path"
|
---|
428 | link_into_fs "src" "${PACKAGE_BASE}/usr/src"
|
---|
429 |
|
---|
430 | if [ -d "$INSTALLATION_MODULES_DIR" ]; then
|
---|
431 | info "Installing additional modules ..."
|
---|
432 | for CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" 2>/dev/null`
|
---|
433 | do
|
---|
434 | echo "$CUR_MODULE" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
435 | done
|
---|
436 | fi
|
---|
437 |
|
---|
438 | for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
|
---|
439 | do
|
---|
440 | mod_${CUR_MODULE}_install
|
---|
441 | if [ $? -ne 0 ]; then
|
---|
442 | info "Error: Failed to install module \"$CUR_MODULE\""
|
---|
443 | if ! test "$FORCE_UPGRADE" = "force"; then
|
---|
444 | exit 1
|
---|
445 | fi
|
---|
446 | fi
|
---|
447 | done
|
---|
448 |
|
---|
449 | # Remember our installation configuration before we call any init scripts
|
---|
450 | cat > "$CONFIG_DIR/$CONFIG" << EOF
|
---|
451 | # $PACKAGE installation record.
|
---|
452 | # Package installation directory
|
---|
453 | INSTALL_DIR='$INSTALLATION_DIR'
|
---|
454 | # Additional installation modules
|
---|
455 | INSTALL_MODULES_DIR='$INSTALLATION_MODULES_DIR'
|
---|
456 | INSTALL_MODULES_LIST='$INSTALLATION_MODULES_LIST'
|
---|
457 | # Package uninstaller. If you repackage this software, please make sure
|
---|
458 | # that this prints a message and returns an error so that the default
|
---|
459 | # uninstaller does not attempt to delete the files installed by your
|
---|
460 | # package.
|
---|
461 | UNINSTALLER='$UNINSTALL'
|
---|
462 | # Package version
|
---|
463 | INSTALL_VER='$INSTALLATION_VER'
|
---|
464 | # Build type and user name for logging purposes
|
---|
465 | BUILD_VBOX_KBUILD_TYPE='$BUILD_BUILDTYPE'
|
---|
466 | BUILD_USERNAME='$USERNAME'
|
---|
467 | EOF
|
---|
468 |
|
---|
469 | # Give the modules the chance to write their stuff
|
---|
470 | # to the installation config as well.
|
---|
471 | if [ -n "${INSTALLATION_MODULES_LIST}" ]; then
|
---|
472 | info "Saving modules configuration ..."
|
---|
473 | for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
|
---|
474 | do
|
---|
475 | echo "`mod_${CUR_MODULE}_config_save`" >> "$CONFIG_DIR/$CONFIG"
|
---|
476 | done
|
---|
477 | fi
|
---|
478 |
|
---|
479 | # Install, set up and start init scripts
|
---|
480 | install_init_script "$INSTALLATION_DIR"/init/vboxadd vboxadd 2>> "$LOGFILE"
|
---|
481 | install_init_script "$INSTALLATION_DIR"/init/vboxadd-service vboxadd-service \
|
---|
482 | 2>> "$LOGFILE"
|
---|
483 | finish_init_script_install
|
---|
484 | addrunlevel vboxadd 2>> "$LOGFILE"
|
---|
485 | addrunlevel vboxadd-service 2>> "$LOGFILE"
|
---|
486 | "$INSTALLATION_DIR"/init/vboxadd setup 2>&1 | tee -a "$LOGFILE"
|
---|
487 | start_init_script vboxadd 2>> "$LOGFILE"
|
---|
488 | start_init_script vboxadd-service 2>> "$LOGFILE"
|
---|
489 |
|
---|
490 | cp $ROUTINES $INSTALLATION_DIR
|
---|
491 | echo $INSTALLATION_DIR/$ROUTINES >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
492 | cat > $INSTALLATION_DIR/$UNINSTALL << EOF
|
---|
493 | #!/bin/sh
|
---|
494 | # Auto-generated uninstallation file
|
---|
495 |
|
---|
496 | PATH=\$PATH:/bin:/sbin:/usr/sbin
|
---|
497 | LOGFILE="/var/log/vboxadd-uninstall.log"
|
---|
498 |
|
---|
499 | # Read routines.sh
|
---|
500 | if ! test -r "$INSTALLATION_DIR/$ROUTINES"; then
|
---|
501 | echo 1>&2 "Required file $ROUTINES not found. Aborting..."
|
---|
502 | return 1
|
---|
503 | fi
|
---|
504 | . "$INSTALLATION_DIR/$ROUTINES"
|
---|
505 |
|
---|
506 | # We need to be run as root
|
---|
507 | check_root
|
---|
508 |
|
---|
509 | create_log "\$LOGFILE"
|
---|
510 |
|
---|
511 | echo 1>&2 "Removing installed version $INSTALLATION_VER of $PACKAGE_NAME..."
|
---|
512 |
|
---|
513 | NO_CLEANUP=""
|
---|
514 | if test "\$1" = "no_cleanup"; then
|
---|
515 | shift
|
---|
516 | NO_CLEANUP="no_cleanup"
|
---|
517 | fi
|
---|
518 |
|
---|
519 | test -r "$CONFIG_DIR/$CONFIG_FILES" || abort "Required file $CONFIG_FILES not found. Aborting..."
|
---|
520 |
|
---|
521 | # Stop and clean up all services
|
---|
522 | if test -r "$INSTALLATION_DIR"/init/vboxadd-service; then
|
---|
523 | stop_init_script vboxadd-service 2>> "\$LOGFILE"
|
---|
524 | delrunlevel vboxadd-service 2>> "\$LOGFILE"
|
---|
525 | remove_init_script vboxadd-service 2>> "\$LOGFILE"
|
---|
526 | fi
|
---|
527 | if test -r "$INSTALLATION_DIR"/init/vboxadd; then
|
---|
528 | stop_init_script vboxadd 2>> "\$LOGFILE"
|
---|
529 | test -n "\$NO_CLEANUP" || "$INSTALLATION_DIR"/init/vboxadd cleanup 2>> "\$LOGFILE"
|
---|
530 | delrunlevel vboxadd 2>> "\$LOGFILE"
|
---|
531 | remove_init_script vboxadd 2>> "\$LOGFILE"
|
---|
532 | fi
|
---|
533 | finish_init_script_install
|
---|
534 |
|
---|
535 | # Load all modules
|
---|
536 | # Important: This needs to be done before loading the configuration
|
---|
537 | # value below to not override values which are set to a default
|
---|
538 | # value in the modules itself.
|
---|
539 | for CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" -name "module-*" 2>/dev/null`
|
---|
540 | do
|
---|
541 | . "\$CUR_MODULE"
|
---|
542 | done
|
---|
543 |
|
---|
544 | # Load configuration values
|
---|
545 | test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
|
---|
546 |
|
---|
547 | # Call uninstallation initialization of all modules
|
---|
548 | for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
|
---|
549 | do
|
---|
550 | if test -z "\$CUR_MODULE"; then
|
---|
551 | continue
|
---|
552 | fi
|
---|
553 | mod_\${CUR_MODULE}_pre_uninstall
|
---|
554 | if [ $? -ne 0 ]; then
|
---|
555 | echo 1>&2 "Module \"\$CUR_MODULE\" failed to initialize uninstallation"
|
---|
556 | # Continue initialization.
|
---|
557 | fi
|
---|
558 | done
|
---|
559 |
|
---|
560 | # Call uninstallation of all modules
|
---|
561 | for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
|
---|
562 | do
|
---|
563 | if test -z "\$CUR_MODULE"; then
|
---|
564 | continue
|
---|
565 | fi
|
---|
566 | mod_\${CUR_MODULE}_uninstall
|
---|
567 | if [ $? -ne 0 ]; then
|
---|
568 | echo 1>&2 "Module \"\$CUR_MODULE\" failed to uninstall"
|
---|
569 | # Continue uninstallation.
|
---|
570 | fi
|
---|
571 | done
|
---|
572 |
|
---|
573 | # And remove all files and empty installation directories
|
---|
574 | # Remove any non-directory entries
|
---|
575 | cat "$CONFIG_DIR/$CONFIG_FILES" | xargs rm 2>/dev/null
|
---|
576 | # Remove any empty (of files) directories in the file list
|
---|
577 | cat "$CONFIG_DIR/$CONFIG_FILES" |
|
---|
578 | while read file; do
|
---|
579 | case "\$file" in
|
---|
580 | */)
|
---|
581 | test -d "\$file" &&
|
---|
582 | find "\$file" -depth -type d -exec rmdir '{}' ';' 2>/dev/null
|
---|
583 | ;;
|
---|
584 | esac
|
---|
585 | done
|
---|
586 |
|
---|
587 | # Remove configuration files
|
---|
588 | rm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
|
---|
589 | rm "$CONFIG_DIR/$CONFIG" 2>/dev/null
|
---|
590 | rmdir "$CONFIG_DIR" 2>/dev/null
|
---|
591 | exit 0
|
---|
592 | EOF
|
---|
593 | chmod 0755 $INSTALLATION_DIR/$UNINSTALL
|
---|
594 | echo $INSTALLATION_DIR/$UNINSTALL >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
595 | test -n "$REMOVE_INSTALLATION_DIR" &&
|
---|
596 | echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
597 |
|
---|
598 | cat > "${PUBLIC_UNINSTALL_HOOK}" << EOF
|
---|
599 | #!/bin/sh
|
---|
600 | # This executable provides a well-known way to uninstall VirtualBox Guest
|
---|
601 | # Additions in order to re-install them from a different source. A common case
|
---|
602 | # is uninstalling distribution-provide Additions to install the version provided
|
---|
603 | # by VirtualBox. Distributions should put the right command in here to do the
|
---|
604 | # removal, e.g. "dnf remove VirtualBox-guest-additions". Leaving kernel modules
|
---|
605 | # provided by the distribution kernel package in place is acceptable if the
|
---|
606 | # location does not clash with the VirtualBox-provided module location (misc).
|
---|
607 | $INSTALLATION_DIR/$UNINSTALL
|
---|
608 | EOF
|
---|
609 | chmod 0755 "${PUBLIC_UNINSTALL_HOOK}"
|
---|
610 | echo "$PUBLIC_UNINSTALL_HOOK" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
611 |
|
---|
612 | # Test for a problem with old Mesa versions which stopped our 3D libraries
|
---|
613 | # from working. Known to affect Debian 7.11, probably OL/RHEL 5.
|
---|
614 | # The problem was that the system Mesa library had an ABI note, which caused
|
---|
615 | # ldconfig to always prefer it to ours.
|
---|
616 | if ldconfig -p | grep -q "libGL.so.1.*Linux 2.4"; then
|
---|
617 | gl_with_abi=`ldconfig -p | grep "libGL.so.1.*Linux 2.4" | sed 's/.*=> //'`
|
---|
618 | cat >&2 << EOF
|
---|
619 | This system appears to be running a version of Mesa with a known problem
|
---|
620 | which will prevent VirtualBox 3D pass-through from working. See
|
---|
621 | https://bugs.freedesktop.org/show_bug.cgi?id=26663
|
---|
622 | The following, run as root should fix this, though you will have to run it
|
---|
623 | again if the system version of Mesa is updated:
|
---|
624 | EOF
|
---|
625 | for i in ${gl_with_abi}; do
|
---|
626 | echo >&2 " strip -R .note.ABI-tag ${i}"
|
---|
627 | done
|
---|
628 | echo >&2 " ldconfig"
|
---|
629 | fi
|
---|
630 |
|
---|
631 | # setuid bit of our drm client as drm ioctl calls
|
---|
632 | # need to be done by elevated privileges
|
---|
633 | chmod 4755 "$INSTALLATION_DIR"/bin/VBoxDRMClient
|
---|
634 |
|
---|
635 | # And do a final test as to whether the kernel modules were properly created
|
---|
636 | # and loaded. Return 0 if both are true, 1 if the modules could not be built
|
---|
637 | # or loaded (except due to already running older modules) and 2 if already
|
---|
638 | # running modules probably prevented new ones from loading. vboxvideo is
|
---|
639 | # currently not tested.
|
---|
640 | # Assume that we have already printed enough messages by now and stay silent.
|
---|
641 | modinfo vboxguest >/dev/null 2>&1 || exit 1
|
---|
642 | lsmod | grep -q vboxguest || exit 1
|
---|
643 | test -n "${MODULES_STOPPED}" || exit 2
|
---|
644 | exit 0
|
---|