VirtualBox

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

Last change on this file since 104853 was 104700, checked in by vboxsync, 7 months ago

Installer: Rebranding changes. Left out signing-related stuff, needs to be done separately. bugref:10690

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1#!/bin/sh
2## @file
3# Oracle 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
99# Get effective user name to use it in order to compose XPCOM IPC socket path.
100VBOX_EFFECTIVE_USER="$(whoami)"
101if [ -z "$VBOX_EFFECTIVE_USER" ]; then
102 cat << EOF
103WARNING: Unable to detect effective user name. VirtualBox might run incorrectly.
104EOF
105fi
106
107# Variables LOGNAME and USER are used by XPCOM code in order to
108# compose IPC socket path. If they set to something which is different
109# from the effective user name, it might result in misbehavior.
110# Setting VBOX_IPC_SOCKETID will tell XPCOM code which path it should use explicitly.
111[ -n "$LOGNAME" ] && [ "$LOGNAME" = "$VBOX_EFFECTIVE_USER" ] || vbox_override_env="1"
112[ -n "$USER" ] && [ "$USER" = "$VBOX_EFFECTIVE_USER" ] || vbox_override_env="1"
113
114if [ -n "$vbox_override_env" ]; then
115cat << EOF
116WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
117EOF
118 export VBOX_IPC_SOCKETID="$VBOX_EFFECTIVE_USER"
119fi
120
121SERVER_PID=`ps -U "$VBOX_EFFECTIVE_USER" | grep VBoxSVC | awk '{ print $1 }'`
122if [ -z "$SERVER_PID" ]; then
123 # Server not running yet/anymore, cleanup socket path.
124 # See IPC_GetDefaultSocketPath()!
125 rm -rf "/tmp/.vbox-$VBOX_EFFECTIVE_USER-ipc" > /dev/null 2>&1
126fi
127
128if [ "$SHUTDOWN" = "true" ]; then
129 if [ -n "$SERVER_PID" ]; then
130 kill -TERM $SERVER_PID
131 sleep 2
132 fi
133 exit 0
134fi
135
136APP=`basename $0`
137case "$APP" in
138 VirtualBox|virtualbox)
139 exec "$INSTALL_DIR/VirtualBox" "$@"
140 ;;
141 VirtualBoxVM|virtualboxvm)
142 exec "$INSTALL_DIR/VirtualBoxVM" "$@"
143 ;;
144 VBoxManage|vboxmanage)
145 exec "$INSTALL_DIR/VBoxManage" "$@"
146 ;;
147 VBoxSDL|vboxsdl)
148 exec "$INSTALL_DIR/VBoxSDL" "$@"
149 ;;
150 VBoxVRDP|VBoxHeadless|vboxheadless)
151 exec "$INSTALL_DIR/VBoxHeadless" "$@"
152 ;;
153 VBoxAutostart|vboxautostart)
154 exec "$INSTALL_DIR/VBoxAutostart" "$@"
155 ;;
156 VBoxBalloonCtrl|vboxballoonctrl)
157 exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
158 ;;
159 VBoxBugReport|vboxbugreport)
160 exec "$INSTALL_DIR/VBoxBugReport" "$@"
161 ;;
162 VBoxDTrace|vboxdtrace)
163 exec "$INSTALL_DIR/VBoxDTrace" "$@"
164 ;;
165 VBoxAudioTest|vboxaudiotest|vkat)
166 exec "$INSTALL_DIR/VBoxAudioTest" "$@"
167 ;;
168 vboxwebsrv)
169 exec "$INSTALL_DIR/vboxwebsrv" "$@"
170 ;;
171 *)
172 echo "Unknown application - $APP"
173 exit 1
174 ;;
175esac
176exit 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