| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
PATH="/usr/bin:/bin:/usr/sbin:/sbin" |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
if [ "$1" = "shutdown" ]; then |
|---|
| 26 |
SHUTDOWN="true" |
|---|
| 27 |
elif ! lsmod|grep -q vboxdrv; then |
|---|
| 28 |
cat << EOF |
|---|
| 29 |
WARNING: The vboxdrv kernel module is not loaded. Either there is no module |
|---|
| 30 |
available for the current kernel (`uname -r`) or it failed to |
|---|
| 31 |
load. Please recompile the kernel module and install it by |
|---|
| 32 |
|
|---|
| 33 |
sudo /etc/init.d/vboxdrv setup |
|---|
| 34 |
|
|---|
| 35 |
You will not be able to start VMs until this problem is fixed. |
|---|
| 36 |
EOF |
|---|
| 37 |
elif [ ! -c /dev/vboxdrv ]; then |
|---|
| 38 |
cat << EOF |
|---|
| 39 |
WARNING: The character device /dev/vboxdrv does not exist. Try |
|---|
| 40 |
|
|---|
| 41 |
sudo /etc/init.d/vboxdrv restart |
|---|
| 42 |
|
|---|
| 43 |
and if that is not successful, try to re-install the package. |
|---|
| 44 |
|
|---|
| 45 |
You will not be able to start VMs until this problem is fixed. |
|---|
| 46 |
EOF |
|---|
| 47 |
fi |
|---|
| 48 |
|
|---|
| 49 |
if [ -f /etc/vbox/module_not_compiled ]; then |
|---|
| 50 |
cat << EOF |
|---|
| 51 |
WARNING: The compilation of the vboxdrv.ko kernel module failed during the |
|---|
| 52 |
installation for some reason. Starting a VM will not be possible. |
|---|
| 53 |
Please consult the User Manual for build instructions. |
|---|
| 54 |
EOF |
|---|
| 55 |
fi |
|---|
| 56 |
|
|---|
| 57 |
SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'` |
|---|
| 58 |
if [ -z "$SERVER_PID" ]; then |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
if [ -n "$LOGNAME" ]; then |
|---|
| 62 |
rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1 |
|---|
| 63 |
else |
|---|
| 64 |
rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1 |
|---|
| 65 |
fi |
|---|
| 66 |
fi |
|---|
| 67 |
|
|---|
| 68 |
if [ "$SHUTDOWN" = "true" ]; then |
|---|
| 69 |
if [ -n "$SERVER_PID" ]; then |
|---|
| 70 |
kill -TERM $SERVER_PID |
|---|
| 71 |
sleep 2 |
|---|
| 72 |
fi |
|---|
| 73 |
exit 0 |
|---|
| 74 |
fi |
|---|
| 75 |
|
|---|
| 76 |
APP=`which $0` |
|---|
| 77 |
APP=${APP |
|---|
| 78 |
case "$APP" in |
|---|
| 79 |
VirtualBox) |
|---|
| 80 |
exec "/usr/lib/virtualbox-ose/VirtualBox" "$@" |
|---|
| 81 |
;; |
|---|
| 82 |
VBoxManage) |
|---|
| 83 |
exec "/usr/lib/virtualbox-ose/VBoxManage" "$@" |
|---|
| 84 |
;; |
|---|
| 85 |
VBoxSDL) |
|---|
| 86 |
exec "/usr/lib/virtualbox-ose/VBoxSDL" "$@" |
|---|
| 87 |
;; |
|---|
| 88 |
VBoxVRDP) |
|---|
| 89 |
exec "/usr/lib/virtualbox-ose/VBoxVRDP" "$@" |
|---|
| 90 |
;; |
|---|
| 91 |
VBoxHeadless) |
|---|
| 92 |
exec "/usr/lib/virtualbox-ose/VBoxHeadless" "$@" |
|---|
| 93 |
;; |
|---|
| 94 |
*) |
|---|
| 95 |
echo "Unknown application - $APP" |
|---|
| 96 |
;; |
|---|
| 97 |
esac |
|---|