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