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 | CONFIG="/etc/vbox/vbox.cfg"
|
---|
17 |
|
---|
18 | if [ ! -r "$CONFIG" ]; then
|
---|
19 | echo "Could not find VirtualBox installation. Please reinstall."
|
---|
20 | exit 1
|
---|
21 | fi
|
---|
22 |
|
---|
23 | . "$CONFIG"
|
---|
24 |
|
---|
25 | # Note: This script must not fail if the module was not successfully installed
|
---|
26 | # because the user might not want to run a VM but only change VM params!
|
---|
27 |
|
---|
28 | if [ "$1" = "shutdown" ]; then
|
---|
29 | SHUTDOWN="true"
|
---|
30 | elif ! lsmod|grep -q vboxdrv; then
|
---|
31 | cat << EOF
|
---|
32 | WARNING: The vboxdrv kernel module is not loaded. Either there is no module
|
---|
33 | available for the current kernel (`uname -r`) or it failed to
|
---|
34 | load. Please recompile the kernel module and install it by
|
---|
35 |
|
---|
36 | sudo /etc/init.d/vboxdrv setup
|
---|
37 |
|
---|
38 | You will not be able to start VMs until this problem is fixed.
|
---|
39 | EOF
|
---|
40 | elif [ ! -c /dev/vboxdrv ]; then
|
---|
41 | cat << EOF
|
---|
42 | WARNING: The character device /dev/vboxdrv does not exist. Try
|
---|
43 |
|
---|
44 | sudo /etc/init.d/vboxdrv restart
|
---|
45 |
|
---|
46 | and if that is not successful, try to re-install the package.
|
---|
47 |
|
---|
48 | You will not be able to start VMs until this problem is fixed.
|
---|
49 | EOF
|
---|
50 | elif [ ! -w /dev/vboxdrv ]; then
|
---|
51 | if [ "`id | grep vboxusers`" = "" ]; then
|
---|
52 | cat << EOF
|
---|
53 | WARNING: You are not a member of the "vboxusers" group. Please add yourself
|
---|
54 | to this group before starting VirtualBox.
|
---|
55 |
|
---|
56 | You will not be able to start VMs until this problem is fixed.
|
---|
57 | EOF
|
---|
58 | else
|
---|
59 | cat << EOF
|
---|
60 | WARNING: /dev/vboxdrv not writable for some reason. If you recently added the
|
---|
61 | current user to the vboxusers group then you have to logout and
|
---|
62 | re-login to take the change effect.
|
---|
63 |
|
---|
64 | You will not be able to start VMs until this problem is fixed.
|
---|
65 | EOF
|
---|
66 | fi
|
---|
67 | fi
|
---|
68 |
|
---|
69 | if [ -f /etc/vbox/module_not_compiled ]; then
|
---|
70 | cat << EOF
|
---|
71 | WARNING: The compilation of the vboxdrv.ko kernel module failed during the
|
---|
72 | installation for some reason. Starting a VM will not be possible.
|
---|
73 | Please consult the User Manual for build instructions.
|
---|
74 | EOF
|
---|
75 | fi
|
---|
76 |
|
---|
77 | export LD_LIBRARY_PATH="$INSTALL_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
---|
78 |
|
---|
79 | SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
|
---|
80 | if [ -z "$SERVER_PID" ]; then
|
---|
81 | # Server not running yet/anymore, cleanup socket path.
|
---|
82 | # See IPC_GetDefaultSocketPath()!
|
---|
83 | if [ -n "$LOGNAME" ]; then
|
---|
84 | rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
|
---|
85 | else
|
---|
86 | rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
|
---|
87 | fi
|
---|
88 | fi
|
---|
89 |
|
---|
90 | if [ "$SHUTDOWN" = "true" ]; then
|
---|
91 | if [ -n "$SERVER_PID" ]; then
|
---|
92 | kill -TERM $SERVER_PID
|
---|
93 | sleep 2
|
---|
94 | fi
|
---|
95 | exit 0
|
---|
96 | fi
|
---|
97 |
|
---|
98 | APP=`which $0`
|
---|
99 | APP=${APP##/*/}
|
---|
100 | case "$APP" in
|
---|
101 | VirtualBox)
|
---|
102 | exec "$INSTALL_DIR/VirtualBox" "$@"
|
---|
103 | ;;
|
---|
104 | VBoxManage)
|
---|
105 | exec "$INSTALL_DIR/VBoxManage" "$@"
|
---|
106 | ;;
|
---|
107 | VBoxSDL)
|
---|
108 | exec "$INSTALL_DIR/VBoxSDL" "$@"
|
---|
109 | ;;
|
---|
110 | VBoxVRDP)
|
---|
111 | exec "$INSTALL_DIR/VBoxVRDP" "$@"
|
---|
112 | ;;
|
---|
113 | *)
|
---|
114 | echo "Unknown application - $APP"
|
---|
115 | ;;
|
---|
116 | esac
|
---|