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