install.sh revision 45c2de093cddc990b8d1583aa49b9a40de7a3d97
#
# Oracle VM VirtualBox
# VirtualBox linux installation script
#
# Copyright (C) 2007-2011 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Include routines and utilities needed by the installer
. ./routines.sh
#include installer-utils.sh
VERSION="_VERSION_"
SVNREV="_SVNREV_"
BUILD="_BUILD_"
ARCH="_ARCH_"
HARDENED="_HARDENED_"
CONFIG_DIR="/etc/vbox"
CONFIG_FILES="filelist"
GROUPNAME="vboxusers"
PYTHON="_PYTHON_"
ACTION=""
SELF=$1
if [ -n "$HARDENED" ]; then
VBOXDRV_MODE=0600
VBOXDRV_GRP="root"
else
VBOXDRV_MODE=0660
fi
VBOXUSB_MODE=0664
##############################################################################
# Helper routines #
##############################################################################
info ""
info "Usage: install | uninstall"
info ""
info "Example:"
exit 1
}
}
# This routine makes sure that there is no previous installation of
# VirtualBox other than one installed using this install script or a
# compatible method. We do this by checking for any of the VirtualBox
# the installation directory, then we assume that they are from an
# incompatible previous installation.
## Helper routine: test for a particular VirtualBox binary and see if it
## is a link into a previous installation directory
##
## Arguments: 1) the binary to search for and
## 2) the installation directory (if any)
## Returns: false if an incompatible version was detected, true otherwise
binary=$1
install_dir=$2
)
}
## Main routine
##
## Argument: the directory where the previous installation should be
## located. If this is empty, then we will assume that any
## installation of VirtualBox found is incompatible with this one.
## Returns: false if an incompatible installation was found, true otherwise
install_dir=$1
# These should all be symlinks into the installation folder
}
##############################################################################
# Main script #
##############################################################################
# Make sure that we were invoked as root...
# Set up logging before anything else
# Now stop the ballon control service otherwise it will keep VBoxSVC running
# Now stop the web service otherwise it will keep VBoxSVC running
# Now check if no VBoxSVC daemon is running
log ""
log "Testing system setup..."
# Sanity check: figure out whether build arch matches uname arch
cpu="x86"
;;
cpu="amd64"
;;
esac
exit 1
fi
# Check that the system is setup correctly for the installation
info "Problems were found which would prevent VirtualBox from installing."
info "Please correct these problems and try again."
log "Giving up due to the problems mentioned above."
exit 1
else
log "System setup appears correct."
log ""
fi
# Sensible default actions
ACTION="install"
BUILD_MODULE="true"
while true
do
if [ "$2" = "" ]; then
break
fi
shift
case "$1" in
ACTION="install"
;;
ACTION="uninstall"
;;
;;
# Legacy option
;;
BUILD_MODULE=""
;;
*)
if [ "$ACTION" = "" ]; then
info "Unknown command '$1'."
fi
info "Specifying an installation path is not allowed -- using /opt/VirtualBox!"
;;
esac
done
if [ "$ACTION" = "install" ]; then
# Find previous installation
if [ ! -r $CONFIG_DIR/$CONFIG ]; then
else
fi
then
info "You appear to have a version of VirtualBox on your system which was installed"
info "from a different source or using a different type of installer (or a damaged"
info "installation of VirtualBox). We strongly recommend that you remove it before"
info "installing this version of VirtualBox."
info "Do you wish to continue anyway? [yes or no]"
then
info "Cancelling installation."
log "User requested cancellation of the installation"
exit 1
fi
fi
# Terminate Server and VBoxNetDHCP if running
# Remove previous installation
then
info "If you are upgrading from VirtualBox 1.5 or older and if some of your virtual"
info "machines have saved states, then the saved state information will be lost"
info "after the upgrade and will have to be discarded. If you do not want this then"
info "you can cancel the upgrade now."
info "Do you wish to continue? [yes or no]"
then
info "Cancelling upgrade."
log "User requested cancellation of the installation"
exit 1
fi
fi
then
# Not doing this can confuse dkms
info "Rebuilding the kernel module after version change"
BUILD_MODULE=true
fi
if [ -n "$PREV_INSTALLATION" ]; then
info "Removing previous installation of VirtualBox $INSTALL_VER$INSTALL_REV from $PREV_INSTALLATION"
log "Removing previous installation of VirtualBox $INSTALL_VER$INSTALL_REV from $PREV_INSTALLATION"
log ""
if [ "$BUILD_MODULE" = "true" ]; then
if [ -n "$DKMS" ]
then
fi
# OSE doesn't always have the initscript
module_loaded && {
info "Warning: could not stop VirtualBox kernel module."
info "Please restart your system to apply changes."
log "Unable to remove the old VirtualBox kernel module."
log " An old version of VirtualBox may be running."
}
else
fi
. ./uninstall.sh
fi
info "Installing VirtualBox to $INSTALLATION_DIR"
log "Installing VirtualBox to $INSTALLATION_DIR"
log ""
# Verify the archive
RETVAL=$?
if [ $RETVAL != 0 ]; then
abort "Error installing VirtualBox. Installation aborted"
fi
# Create installation directory and install
RETVAL=$?
if [ $RETVAL != 0 ]; then
cwd=`pwd`
cd $pwd
abort "Error installing VirtualBox. Installation aborted"
fi
# XXX SELinux: allow text relocation entries
# Hardened build: Mark selected binaries set-user-ID-on-execution,
# create symlinks for working around unsupported $ORIGIN/.. in VBoxC.so (setuid),
# and finally make sure the directory is only writable by the user (paranoid).
if [ -n "$HARDENED" ]; then
fi
# This binary needs to be suid root in any case, even if not hardened
# Install runlevel scripts
# Note: vboxdrv is also handled by setup_init_script. This function will
# use chkconfig to adjust the sequence numbers, therefore vboxdrv
# numbers here should match the numbers in the vboxdrv.sh check
# header!
# Create users group
# Create symlinks to start binaries
# Unity and Nautilus seem to look here for their icons
# Convenience symlinks. The creation fails if the FS is not case sensitive
# Icons
cur=`pwd`
for i in *; do
cd $i
for j in *; do
if [ "$j" = "virtualbox.png" ]; then
else
fi
fi
done
fi
cd -
done
cd $cur
# Update the MIME database
# Update the desktop database
# If Python is available, install Python bindings
if [ -n "$PYTHON" ]; then
fi
# Make kernel module
MODULE_FAILED="false"
if [ "$BUILD_MODULE" = "true" ]
then
info "Building the VirtualBox kernel modules"
log "Output from the module build process (the Linux kernel build system) follows:"
cur=`pwd`
log ""
# Start VirtualBox kernel module
info "Failed to load the kernel module."
MODULE_FAILED="true"
fi
log ""
log "End of the output from the Linux kernel build system."
cd $cur
fi
info ""
if [ ! "$MODULE_FAILED" = "true" ]
then
info "VirtualBox has been installed successfully."
else
info "VirtualBox has been installed successfully, but the kernel module could not"
info "be built. When you have fixed the problems preventing this, execute"
info "as administrator to build it."
fi
info ""
info "You will find useful information about using VirtualBox in the user manual"
info "and in the user FAQ"
info ""
info "We hope that you enjoy using VirtualBox."
info ""
log "Installation successful"
elif [ "$ACTION" = "uninstall" ]; then
. ./uninstall.sh
fi
exit $RC_SCRIPT