| 1 | | #!/bin/sh |
| 2 | | # |
| 3 | | # innotek VirtualBox |
| 4 | | # |
| 5 | | # Copyright (C) 2006-2007 innotek GmbH |
| 6 | | # |
| 7 | | # This file is part of VirtualBox Open Source Edition (OSE), as |
| 8 | | # available from http://www.virtualbox.org. This file is free software; |
| 9 | | # you can redistribute it and/or modify it under the terms of the GNU |
| 10 | | # General Public License as published by the Free Software Foundation, |
| 11 | | # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE |
| 12 | | # distribution. VirtualBox OSE is distributed in the hope that it will |
| 13 | | # be useful, but WITHOUT ANY WARRANTY of any kind. |
| 14 | | |
| 15 | | PATH="/usr/bin:/bin:/usr/sbin:/sbin" |
| 16 | | APP_LIB_PATH=/usr/lib/%PKGNAME% |
| 17 | | |
| 18 | | # Note: This script must not fail if the module was not successfully installed |
| 19 | | # because the user might not want to run a VM but only change VM params! |
| 20 | | |
| 21 | | if [ "$1" = "shutdown" ]; then |
| 22 | | SHUTDOWN="true" |
| 23 | | elif ! lsmod|grep -q vboxdrv; then |
| 24 | | cat << EOF |
| 25 | | WARNING: The vboxdrv kernel module is not loaded. Either there is no module |
| 26 | | available for the current kernel (`uname -r`) or it failed to |
| 27 | | load. Please recompile the kernel module and install it by |
| 28 | | |
| 29 | | sudo /etc/init.d/vboxdrv setup |
| 30 | | |
| 31 | | You will not be able to start VMs until this problem is fixed. |
| 32 | | EOF |
| 33 | | elif [ ! -c /dev/vboxdrv ]; then |
| 34 | | cat << EOF |
| 35 | | WARNING: The character device /dev/vboxdrv does not exist. Try |
| 36 | | |
| 37 | | sudo /etc/init.d/virtualbox restart |
| 38 | | |
| 39 | | and if that is not successful, try to re-install the package. |
| 40 | | |
| 41 | | You will not be able to start VMs until this problem is fixed. |
| 42 | | EOF |
| 43 | | elif [ ! -w /dev/vboxdrv ]; then |
| 44 | | if [ "`id | grep vboxusers`" = "" ]; then |
| 45 | | cat << EOF |
| 46 | | WARNING: You are not a member of the "vboxusers" group. Please add yourself |
| 47 | | to this group before starting VirtualBox. |
| 48 | | |
| 49 | | You will not be able to start VMs until this problem is fixed. |
| 50 | | EOF |
| 51 | | else |
| 52 | | cat << EOF |
| 53 | | WARNING: /dev/vboxdrv not writable for some reason. If you recently added the |
| 54 | | current user to the vboxusers group then you have to logout and |
| 55 | | re-login to take the change effect. |
| 56 | | |
| 57 | | You will not be able to start VMs until this problem is fixed. |
| 58 | | EOF |
| 59 | | fi |
| 60 | | fi |
| 61 | | |
| 62 | | if [ -f /etc/vbox/module_not_compiled ]; then |
| 63 | | cat << EOF |
| 64 | | WARNING: The compilation of the vboxdrv.ko kernel module failed during the |
| 65 | | installation for some reason. Starting a VM will not be possible. |
| 66 | | Please consult the User Manual for build instructions. |
| 67 | | EOF |
| 68 | | fi |
| 69 | | |
| 70 | | SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'` |
| 71 | | if [ -z "$SERVER_PID" ]; then |
| 72 | | # Server not running yet/anymore, cleanup socket path. |
| 73 | | # See IPC_GetDefaultSocketPath()! |
| 74 | | if [ -n "$LOGNAME" ]; then |
| 75 | | rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1 |
| 76 | | else |
| 77 | | rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1 |
| 78 | | fi |
| 79 | | fi |
| 80 | | |
| 81 | | if [ "$SHUTDOWN" = "true" ]; then |
| 82 | | if [ -n "$SERVER_PID" ]; then |
| 83 | | kill -TERM $SERVER_PID |
| 84 | | sleep 2 |
| 85 | | fi |
| 86 | | exit 0 |
| 87 | | fi |
| 88 | | |
| 89 | | APP=`which $0` |
| 90 | | APP=${APP##/*/} |
| 91 | | case "$APP" in |
| 92 | | VirtualBox) |
| 93 | | exec "$APP_LIB_PATH/VirtualBox" "$@" |
| 94 | | ;; |
| 95 | | VBoxManage) |
| 96 | | exec "$APP_LIB_PATH/VBoxManage" "$@" |
| 97 | | ;; |
| 98 | | VBoxSDL) |
| 99 | | exec "$APP_LIB_PATH/VBoxSDL" "$@" |
| 100 | | ;; |
| 101 | | VBoxVRDP) |
| 102 | | exec "$APP_LIB_PATH/VBoxVRDP" "$@" |
| 103 | | ;; |
| 104 | | *) |
| 105 | | echo "Unknown application - $APP" |
| 106 | | ;; |
| 107 | | esac |