run-inst.sh revision bf5a2ed371c0a47483665fc30b0765a8d80b6b1f
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Oracle VM VirtualBox
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# VirtualBox Makeself installation starter script
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# for Linux Guest Additions
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Copyright (C) 2006-2013 Oracle Corporation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# available from http://www.virtualbox.org. This file is free software;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# you can redistribute it and/or modify it under the terms of the GNU
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# General Public License (GPL) as published by the Free Software
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync# This is a stub installation script to be included in VirtualBox Makeself
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync# installers which removes any previous installations of the package, unpacks
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync# the package into the filesystem (by default under /opt) and starts the real
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync# installation script.
e0778e583cb4a0bdc9bcc48f5957e00a01108388vboxsync# Note: These variable names must *not* clash with variables in $CONFIG_DIR/$CONFIG!
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync## @todo r=andy: Explain options like "force" and "no_setup" -- not self-explanatory
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# to the user.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync info "Usage: $SELF install [<installation directory>]"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Create a symlink in the filesystem and add it to the list of package files
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync # The name of the actual symlink file. Must be an absolute path to a
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync { echo 1>&2 "$self: no target specified"; return 1; }
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync { echo 1>&2 "$self: link directory $link_dir does not exist"; return 1; }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync { echo 1>&2 "$self: link file "$link" already exists"; return 1; }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync { echo 1>&2 "$self: link file name is not absolute"; return 1; }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Create symbolic links targeting all files in a directory in another
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync# directory in the filesystem
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Look for broken installations or installations without a known uninstaller
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync# and try to clean them up, asking the user first.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync cat 1>&2 << EOF
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncYou appear to have a version of the _PACKAGE_ software
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncon your system which was installed from a different source or using a
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncdifferent type of installer. If you installed it from a package from your
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncLinux distribution or if it is a default part of the system then we strongly
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncrecommend that you cancel this installation and remove it properly before
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncinstalling this version. If this is simply an older or a damaged
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncinstallation you may safely proceed.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncDo you wish to continue anyway? [yes or no]
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync # Stop what we can in the way of services and remove them from the
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync test -x "./$i" && "./$i" cleanup 1>&2 2>> "$LOGFILE"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync rm -f "/usr/lib/$PACKAGE" "/usr/lib64/$PACKAGE" "/usr/share/$PACKAGE"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Check architecture
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if test -d "/usr/lib64"; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncif [ ! -r "$ARCH_PACKAGE" ]; then
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync# Sensible default actions
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if [ -z "$MY_END_OF_OPTIONS" ]; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync ## @todo Add per-module options handling, e.g. --lightdm-greeter-dir
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # or --lightdm-config
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync ## @todo Add listing all available modules (+ their options, e.g.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # with callback mod_mymod_show_options?)
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Check if corresponding module in installer/module-$1 exists.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Note: Module names may not contain spaces or other funny things.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if [ ! -f "./installer/module-${MODULE_CUR}" ]; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync info "Error: Module \"${MODULE_CUR}\" does not exist."
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Give the module the chance of doing initialization work / checks.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync . "./installer/module-${MODULE_CUR}"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync echo 1>&2 "Module '${MODULE_CUR}' failed to initialize"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Continue initialization.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Add module to the list of modules to handle later.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if test -z "${INSTALLATION_MODULES_LIST}"; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync INSTALLATION_MODULES_LIST="${INSTALLATION_MODULES_LIST} ${MODULE_CUR}"
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync --force|force) # Keep "force" for backwards compatibility.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync # Do not do cleanup of old modules when removing them. For
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync # testing purposes only.
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync# uninstall any previous installation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctest -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncif test -n "$INSTALL_DIR" -a -x "$INSTALL_DIR/$UNINSTALLER"; then
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync abort "Failed to remove existing installation. Aborting..."
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsynctest "$uninstalled" = 0 && def_uninstall "$FORCE_UPGRADE" && uninstalled=1
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync# Set installer modules directory
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncINSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync# install and load installer modules
36a04912b64bea8318327fe0723535f1b3f041b0vboxsyncif [ -d installer ]; then
3933885bc0c2c93436d858a14564c6179ec72872vboxsync install -p -m 755 "$CUR_FILE" "$INSTALLATION_MODULES_DIR"
3933885bc0c2c93436d858a14564c6179ec72872vboxsync info "Error: Failed to copy installer module \"$CUR_FILE\""
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# install the new version
80b09746c07120c881b61b18f30c9c4a2a4af9c5vboxsynctest ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Create a list of the files in the archive, skipping any directories which
80b09746c07120c881b61b18f30c9c4a2a4af9c5vboxsync# already exist in the filesystem.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync while read name; do
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync test ! -d "$fullname" &&
776985d1f8ee71ad78aa1067cce88766803c7b30vboxsyncbzip2 -d -c "$ARCH_PACKAGE" | tar -xf - -C "$INSTALLATION_DIR" || exit 1
bd5c7d04b57ea9dfea041aad6a07cd8823b4e7c0vboxsync# Set symlinks into /usr and /sbin
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync for CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" 2>/dev/null`
2355157d3ea6596738c7c74e803220ad1bd6b4a8vboxsync info "Error: Failed to install module \"$CUR_MODULE\""
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Remember our installation configuration before we call any init scripts
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# $PACKAGE installation record.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Package installation directory
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncINSTALL_DIR='$INSTALLATION_DIR'
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsync# Additional installation modules
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncINSTALL_MODULES_DIR='$INSTALLATION_MODULES_DIR'
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncINSTALL_MODULES_LIST='$INSTALLATION_MODULES_LIST'
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync# Package uninstaller. If you repackage this software, please make sure
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# that this prints a message and returns an error so that the default
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync# uninstaller does not attempt to delete the files installed by your
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsyncUNINSTALLER='$UNINSTALL'
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync# Package version
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncINSTALL_VER='$INSTALLATION_VER'
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsyncINSTALL_REV='$INSTALLATION_REV'
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Build type and user name for logging purposes
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncBUILD_TYPE='$BUILD_TYPE'
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncUSERNAME='$USERNAME'
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync# Give the modules the chance to write their stuff
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# to the installation config as well.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncif [ -n "${INSTALLATION_MODULES_LIST}" ]; then
a1a2e3f1c3ca7d6190c90ff67b7995b50b258794vboxsync echo "`mod_${CUR_MODULE}_config_save`" >> "$CONFIG_DIR/$CONFIG"
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync# Install, set up and start init scripts
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if test -r "$i"; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync test -n "$DO_SETUP" && setup_init_script "`basename "$i"`" 1>&2
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncecho $INSTALLATION_DIR/$ROUTINES >> "$CONFIG_DIR/$CONFIG_FILES"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Auto-generated uninstallation file
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncPATH=\$PATH:/bin:/sbin:/usr/sbin
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsyncLOGFILE="/var/log/$PACKAGE-uninstall.log"
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync# Read routines.sh
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncif ! test -r "$INSTALLATION_DIR/$ROUTINES"; then
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync echo 1>&2 "Required file $ROUTINES not found. Aborting..."
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync. "$INSTALLATION_DIR/$ROUTINES"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# We need to be run as root
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsynccreate_log "\$LOGFILE"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncecho 1>&2 "Removing installed version $INSTALLATION_VER of $PACKAGE_NAME..."
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncNO_CLEANUP=""
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncif test "\$1" = "no_cleanup"; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync NO_CLEANUP="no_cleanup"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsynctest -r "$CONFIG_DIR/$CONFIG_FILES" || abort "Required file $CONFIG_FILES not found. Aborting..."
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Stop and clean up all services
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncfor i in "$INSTALLATION_DIR/init/"*; do
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync if test -r "\$i"; then
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync stop_init_script "\`basename "\$i"\`"
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync test -z "\$NO_CLEANUP" && cleanup_init "\`basename "\$i"\`" 2>> "\$LOGFILE"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync remove_init_script "\`basename "\$i"\`"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Load all modules
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Important: This needs to be done before loading the configuration
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# value below to not override values which are set to a default
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# value in the modules itself.
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncfor CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" -name "module-*" 2>/dev/null`
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync . "\$CUR_MODULE"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync# Load configuration values
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsynctest -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# Call uninstallation initialization of all modules
a425b5e790c27d6a1a2cf738802e9034f0764a00vboxsyncfor CUR_MODULE in "$INSTALLATION_MODULES_LIST"
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if test -z "\$CUR_MODULE"; then
1568d715e75b8d2484ea3dc87f0483d4cf377838vboxsync mod_\${CUR_MODULE}_pre_uninstall
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync if [ $? -ne 0 ]; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync echo 1>&2 "Module \"\$CUR_MODULE\" failed to initialize uninstallation"
aeb9498c4d9854ed42b271541d34c7bad97b4c77vboxsync # Continue initialization.
80e46f984efd827517661c0e081a36014ca41af8vboxsync# Call uninstallation of all modules
80e46f984efd827517661c0e081a36014ca41af8vboxsyncfor CUR_MODULE in "$INSTALLATION_MODULES_LIST"
1e9377d042fa2ea3e2cd78805678f23f64db55f6vboxsync if test -z "\$CUR_MODULE"; then
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync mod_\${CUR_MODULE}_uninstall
aeb9498c4d9854ed42b271541d34c7bad97b4c77vboxsync if [ $? -ne 0 ]; then
aeb9498c4d9854ed42b271541d34c7bad97b4c77vboxsync echo 1>&2 "Module \"\$CUR_MODULE\" failed to uninstall"
174f11bbd5c277153742aa5e6c3bd640bf379547vboxsync # Continue uninstallation.
aeb9498c4d9854ed42b271541d34c7bad97b4c77vboxsync# And remove all files and empty installation directories
aeb9498c4d9854ed42b271541d34c7bad97b4c77vboxsync# Remove any non-directory entries
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsynccat "$CONFIG_DIR/$CONFIG_FILES" | xargs rm 2>/dev/null
bddad5eeab93a98d4ea571ccdf016531bb4318advboxsync# Remove any empty (of files) directories in the file list
bddad5eeab93a98d4ea571ccdf016531bb4318advboxsynccat "$CONFIG_DIR/$CONFIG_FILES" |
824ae3158a8b8f8233fec3f5a12c81f139933698vboxsync while read file; do
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync case "\$file" in
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync test -d "\$file" &&
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsync find "\$file" -depth -type d -exec rmdir '{}' ';' 2>/dev/null
bf88068260ded16af90b7da4867240fbdd9c8017vboxsync# Remove configuration files
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncrm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
3a8aa22ef125135ef67bfc396771bcee15ef02dfvboxsyncrm "$CONFIG_DIR/$CONFIG" 2>/dev/null
bddad5eeab93a98d4ea571ccdf016531bb4318advboxsyncrmdir "$CONFIG_DIR" 2>/dev/null
63b785c3291332a86a9bc473e68f08121368898bvboxsyncecho $INSTALLATION_DIR/$UNINSTALL >> "$CONFIG_DIR/$CONFIG_FILES"