VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/VBox.sh@ 103131

Last change on this file since 103131 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1#!/bin/sh
2## @file
3# Oracle VM VirtualBox startup script, Linux hosts.
4#
5
6#
7# Copyright (C) 2006-2023 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# SPDX-License-Identifier: GPL-3.0-only
26#
27
28PATH="/usr/bin:/bin:/usr/sbin:/sbin"
29
30# The below is GNU-specific. See slightly further down for a version which
31# works on Solaris and OS X.
32TARGET=`readlink -e -- "${0}"` || exit 1
33MY_DIR="${TARGET%/[!/]*}"
34
35# (
36# path="${0}"
37# while test -n "${path}"; do
38# # Make sure we have at least one slash and no leading dash.
39# expr "${path}" : / > /dev/null || path="./${path}"
40# # Filter out bad characters in the path name.
41# expr "${path}" : ".*[*?<>\\]" > /dev/null && exit 1
42# # Catch embedded new-lines and non-existing (or path-relative) files.
43# # $0 should always be absolute when scripts are invoked through "#!".
44# test "`ls -l -d "${path}" 2> /dev/null | wc -l`" -eq 1 || exit 1
45# # Change to the folder containing the file to resolve relative links.
46# folder=`expr "${path}" : "\(.*/\)[^/][^/]*/*$"` || exit 1
47# path=`expr "x\`ls -l -d "${path}"\`" : "[^>]* -> \(.*\)"`
48# cd "${folder}"
49# # If the last path was not a link then we are in the target folder.
50# test -n "${path}" || pwd
51# done
52# )
53
54if test -f /usr/lib/virtualbox/VirtualBox &&
55 test -x /usr/lib/virtualbox/VirtualBox; then
56 INSTALL_DIR=/usr/lib/virtualbox
57elif test -f "${MY_DIR}/VirtualBox" && test -x "${MY_DIR}/VirtualBox"; then
58 INSTALL_DIR="${MY_DIR}"
59else
60 echo "Could not find VirtualBox installation. Please reinstall."
61 exit 1
62fi
63
64# Note: This script must not fail if the module was not successfully installed
65# because the user might not want to run a VM but only change VM params!
66
67if [ "$1" = "shutdown" ]; then
68 SHUTDOWN="true"
69elif ! lsmod|grep -q vboxdrv; then
70 cat << EOF
71WARNING: The vboxdrv kernel module is not loaded. Either there is no module
72 available for the current kernel (`uname -r`) or it failed to
73 load. Please recompile the kernel module and install it by
74
75 sudo /sbin/vboxconfig
76
77 You will not be able to start VMs until this problem is fixed.
78EOF
79elif [ ! -c /dev/vboxdrv ]; then
80 cat << EOF
81WARNING: The character device /dev/vboxdrv does not exist. Try
82
83 sudo /sbin/vboxconfig
84
85 and if that is not successful, try to re-install the package.
86
87 You will not be able to start VMs until this problem is fixed.
88EOF
89fi
90
91if [ -f /etc/vbox/module_not_compiled ]; then
92 cat << EOF
93WARNING: The compilation of the vboxdrv.ko kernel module failed during the
94 installation for some reason. Starting a VM will not be possible.
95 Please consult the User Manual for build instructions.
96EOF
97fi
98
99SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
100if [ -z "$SERVER_PID" ]; then
101 # Server not running yet/anymore, cleanup socket path.
102 # See IPC_GetDefaultSocketPath()!
103 if [ -n "$LOGNAME" ]; then
104 rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
105 else
106 rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
107 fi
108fi
109
110if [ "$SHUTDOWN" = "true" ]; then
111 if [ -n "$SERVER_PID" ]; then
112 kill -TERM $SERVER_PID
113 sleep 2
114 fi
115 exit 0
116fi
117
118APP=`basename $0`
119case "$APP" in
120 VirtualBox|virtualbox)
121 exec "$INSTALL_DIR/VirtualBox" "$@"
122 ;;
123 VirtualBoxVM|virtualboxvm)
124 exec "$INSTALL_DIR/VirtualBoxVM" "$@"
125 ;;
126 VBoxManage|vboxmanage)
127 exec "$INSTALL_DIR/VBoxManage" "$@"
128 ;;
129 VBoxSDL|vboxsdl)
130 exec "$INSTALL_DIR/VBoxSDL" "$@"
131 ;;
132 VBoxVRDP|VBoxHeadless|vboxheadless)
133 exec "$INSTALL_DIR/VBoxHeadless" "$@"
134 ;;
135 VBoxAutostart|vboxautostart)
136 exec "$INSTALL_DIR/VBoxAutostart" "$@"
137 ;;
138 VBoxBalloonCtrl|vboxballoonctrl)
139 exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
140 ;;
141 VBoxBugReport|vboxbugreport)
142 exec "$INSTALL_DIR/VBoxBugReport" "$@"
143 ;;
144 VBoxDTrace|vboxdtrace)
145 exec "$INSTALL_DIR/VBoxDTrace" "$@"
146 ;;
147 VBoxAudioTest|vboxaudiotest|vkat)
148 exec "$INSTALL_DIR/VBoxAudioTest" "$@"
149 ;;
150 vboxwebsrv)
151 exec "$INSTALL_DIR/vboxwebsrv" "$@"
152 ;;
153 *)
154 echo "Unknown application - $APP"
155 exit 1
156 ;;
157esac
158exit 0
Note: See TracBrowser for help on using the repository browser.

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