VirtualBox

Ticket #140: VBox.sh

File VBox.sh, 3.0 KB (added by glasmach, 18 years ago)

Changed VBox.sh

Line 
1#!/bin/sh
2#
3# InnoTek VirtualBox
4#
5# Copyright (C) 2006 InnoTek Systemberatung 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# If you received this file as part of a commercial VirtualBox
16# distribution, then only the terms of your commercial VirtualBox
17# license agreement apply instead of the previous paragraph.
18
19CONFIG="/etc/vbox/vbox.cfg"
20if [ "$VBOX_USER_HOME" = "" ]; then
21 if [ ! -d "$HOME/.VirtualBox" ]; then
22 mkdir -p "$HOME/.VirtualBox"
23 fi
24 LOG="$HOME/.VirtualBox/VBoxSVC.log"
25else
26 if [ ! -d "$VBOX_USER_HOME" ]; then
27 mkdir -p "$VBOX_USER_HOME"
28 fi
29 LOG="$VBOX_USER_HOME/VBoxSVC.log"
30fi
31
32
33if [ ! -r "$CONFIG" ]; then
34 echo "Could not find VirtualBox installation. Please reinstall."
35 exit 1
36fi
37
38if [ "$1" = "shutdown" ]; then
39 SHUTDOWN="true"
40elif [ ! -w /dev/vboxdrv ]; then
41 if [ "`id | grep vboxusers`" = "" ]; then
42 echo 'You are not a member of the "vboxusers" group. Please add yourself to this'
43 echo 'group before starting VirtualBox.'
44 else
45 echo '/dev/vboxdrv not writable for some reason. If you recently added the current'
46 echo 'user to the vboxusers group then you have to logout and re-login to take the'
47 echo 'change effect.'
48 fi
49 exit 1
50fi
51
52. "$CONFIG_DIR/$CONFIG"
53
54# Note: This script must not fail if the module was not successfully installed
55# because the user might not want to run a VM but only change VM params!
56if [ -f /etc/vbox/module_not_compiled ]; then
57 cat << EOF
58WARNING: The compilation of the vboxdrv.ko kernel module failed during the
59 installation for some reason. Starting a VM will not be possible.
60 Please consult the User Manual for build instructions.
61EOF
62fi
63
64export LD_LIBRARY_PATH="$INSTALL_DIR"
65
66SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
67if [ "$SHUTDOWN" = "" ] && [ "$SERVER_PID" = "" ]; then
68 rm -rf /tmp/.vbox-`whoami`-ipc > /dev/null 2>&1
69 [ -f "$LOG.1" ] && mv "$LOG.1" "$LOG.2"
70 [ -f "$LOG.0" ] && mv "$LOG.0" "$LOG.1"
71 [ -f "$LOG" ] && mv "$LOG" "$LOG.0"
72 "$INSTALL_DIR/VBoxSVC" --daemonize > "$LOG" 2>&1
73fi
74
75if [ "$SHUTDOWN" = "true" ]; then
76 if [ "$SERVER_PID" != "" ]; then
77 kill -TERM $SERVER_PID
78 sleep 2
79 fi
80 exit 0
81fi
82
83APP=`which $0`
84APP=${APP##/*/}
85case "$APP" in
86 VirtualBox)
87 exec "$INSTALL_DIR/VirtualBox" "$@"
88 ;;
89 VBoxManage)
90 exec "$INSTALL_DIR/VBoxManage" "$@"
91 ;;
92 VBoxSDL)
93 exec "$INSTALL_DIR/VBoxSDL" "$@"
94 ;;
95 VBoxVRDP)
96 exec "$INSTALL_DIR/VBoxVRDP" "$@"
97 ;;
98 *)
99 echo "Unknown application - $APP"
100 ;;
101esac

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy