VBox.sh revision 0e28a00f1861cf96d2e4d3ca54b9b96a0a59f1e3
af062818b47340eef15700d2f0211576ba3506eevboxsync#!/bin/sh
af062818b47340eef15700d2f0211576ba3506eevboxsync#
af062818b47340eef15700d2f0211576ba3506eevboxsync# Sun xVM VirtualBox
af062818b47340eef15700d2f0211576ba3506eevboxsync#
af062818b47340eef15700d2f0211576ba3506eevboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
af062818b47340eef15700d2f0211576ba3506eevboxsync#
af062818b47340eef15700d2f0211576ba3506eevboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync# available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync# you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync# General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync#
af062818b47340eef15700d2f0211576ba3506eevboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
af062818b47340eef15700d2f0211576ba3506eevboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
af062818b47340eef15700d2f0211576ba3506eevboxsync# additional information or have any questions.
af062818b47340eef15700d2f0211576ba3506eevboxsync#
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncPATH="/usr/bin:/bin:/usr/sbin:/sbin"
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# Note: This script must not fail if the module was not successfully installed
af062818b47340eef15700d2f0211576ba3506eevboxsync# because the user might not want to run a VM but only change VM params!
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncif [ "$1" = "shutdown" ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync SHUTDOWN="true"
af062818b47340eef15700d2f0211576ba3506eevboxsyncelif ! lsmod|grep -q vboxdrv; then
af062818b47340eef15700d2f0211576ba3506eevboxsync cat << EOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncWARNING: The vboxdrv kernel module is not loaded. Either there is no module
af062818b47340eef15700d2f0211576ba3506eevboxsync available for the current kernel (`uname -r`) or it failed to
af062818b47340eef15700d2f0211576ba3506eevboxsync load. Please recompile the kernel module and install it by
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync sudo /etc/init.d/vboxdrv setup
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync You will not be able to start VMs until this problem is fixed.
af062818b47340eef15700d2f0211576ba3506eevboxsyncEOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncelif [ ! -c /dev/vboxdrv ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync cat << EOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncWARNING: The character device /dev/vboxdrv does not exist. Try
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync sudo /etc/init.d/vboxdrv restart
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync and if that is not successful, try to re-install the package.
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync You will not be able to start VMs until this problem is fixed.
af062818b47340eef15700d2f0211576ba3506eevboxsyncEOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncfi
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncif [ -f /etc/vbox/module_not_compiled ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync cat << EOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncWARNING: The compilation of the vboxdrv.ko kernel module failed during the
af062818b47340eef15700d2f0211576ba3506eevboxsync installation for some reason. Starting a VM will not be possible.
af062818b47340eef15700d2f0211576ba3506eevboxsync Please consult the User Manual for build instructions.
af062818b47340eef15700d2f0211576ba3506eevboxsyncEOF
af062818b47340eef15700d2f0211576ba3506eevboxsyncfi
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncSERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
af062818b47340eef15700d2f0211576ba3506eevboxsyncif [ -z "$SERVER_PID" ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync # Server not running yet/anymore, cleanup socket path.
af062818b47340eef15700d2f0211576ba3506eevboxsync # See IPC_GetDefaultSocketPath()!
af062818b47340eef15700d2f0211576ba3506eevboxsync if [ -n "$LOGNAME" ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
af062818b47340eef15700d2f0211576ba3506eevboxsync fi
af062818b47340eef15700d2f0211576ba3506eevboxsyncfi
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncif [ "$SHUTDOWN" = "true" ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync if [ -n "$SERVER_PID" ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync kill -TERM $SERVER_PID
af062818b47340eef15700d2f0211576ba3506eevboxsync sleep 2
af062818b47340eef15700d2f0211576ba3506eevboxsync fi
af062818b47340eef15700d2f0211576ba3506eevboxsync exit 0
af062818b47340eef15700d2f0211576ba3506eevboxsyncfi
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncAPP=`which $0`
af062818b47340eef15700d2f0211576ba3506eevboxsyncAPP=${APP##/*/}
af062818b47340eef15700d2f0211576ba3506eevboxsynccase "$APP" in
af062818b47340eef15700d2f0211576ba3506eevboxsync VirtualBox)
af062818b47340eef15700d2f0211576ba3506eevboxsync exec "/usr/lib/virtualbox-ose/VirtualBox" "$@"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxManage)
af062818b47340eef15700d2f0211576ba3506eevboxsync exec "/usr/lib/virtualbox-ose/VBoxManage" "$@"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxSDL)
af062818b47340eef15700d2f0211576ba3506eevboxsync exec "/usr/lib/virtualbox-ose/VBoxSDL" "$@"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxVRDP)
af062818b47340eef15700d2f0211576ba3506eevboxsync exec "/usr/lib/virtualbox-ose/VBoxVRDP" "$@"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxHeadless)
af062818b47340eef15700d2f0211576ba3506eevboxsync exec "/usr/lib/virtualbox-ose/VBoxHeadless" "$@"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsync *)
af062818b47340eef15700d2f0211576ba3506eevboxsync echo "Unknown application - $APP"
af062818b47340eef15700d2f0211576ba3506eevboxsync ;;
af062818b47340eef15700d2f0211576ba3506eevboxsyncesac
af062818b47340eef15700d2f0211576ba3506eevboxsync