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