VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 6 weeks 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: 5.7 KB
RevLine 
[4050]1#!/bin/sh
[54030]2## @file
[104700]3# Oracle VirtualBox startup script, Linux hosts.
[4050]4#
[54030]5
[5999]6#
[106061]7# Copyright (C) 2006-2024 Oracle and/or its affiliates.
[54030]8#
[96407]9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
[5999]11#
[96407]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#
[4050]27
28PATH="/usr/bin:/bin:/usr/sbin:/sbin"
29
[58323]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%/[!/]*}"
[4050]34
[58323]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
[4050]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
[58090]75 sudo /sbin/vboxconfig
[4050]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
[58090]83 sudo /sbin/vboxconfig
[4050]84
85 and if that is not successful, try to re-install the package.
86
[24387]87 You will not be able to start VMs until this problem is fixed.
[4050]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
[103575]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 }'`
[4050]122if [ -z "$SERVER_PID" ]; then
123 # Server not running yet/anymore, cleanup socket path.
124 # See IPC_GetDefaultSocketPath()!
[103575]125 rm -rf "/tmp/.vbox-$VBOX_EFFECTIVE_USER-ipc" > /dev/null 2>&1
[4050]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
[37255]136APP=`basename $0`
[4050]137case "$APP" in
[37255]138 VirtualBox|virtualbox)
[48787]139 exec "$INSTALL_DIR/VirtualBox" "$@"
[37255]140 ;;
[76608]141 VirtualBoxVM|virtualboxvm)
142 exec "$INSTALL_DIR/VirtualBoxVM" "$@"
143 ;;
[37255]144 VBoxManage|vboxmanage)
[48787]145 exec "$INSTALL_DIR/VBoxManage" "$@"
[37255]146 ;;
147 VBoxSDL|vboxsdl)
[48787]148 exec "$INSTALL_DIR/VBoxSDL" "$@"
[37255]149 ;;
150 VBoxVRDP|VBoxHeadless|vboxheadless)
[48787]151 exec "$INSTALL_DIR/VBoxHeadless" "$@"
[37255]152 ;;
[42119]153 VBoxAutostart|vboxautostart)
[48787]154 exec "$INSTALL_DIR/VBoxAutostart" "$@"
[42119]155 ;;
[37255]156 VBoxBalloonCtrl|vboxballoonctrl)
[48787]157 exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
[37255]158 ;;
[61998]159 VBoxBugReport|vboxbugreport)
160 exec "$INSTALL_DIR/VBoxBugReport" "$@"
161 ;;
[54030]162 VBoxDTrace|vboxdtrace)
163 exec "$INSTALL_DIR/VBoxDTrace" "$@"
164 ;;
[89669]165 VBoxAudioTest|vboxaudiotest|vkat)
166 exec "$INSTALL_DIR/VBoxAudioTest" "$@"
167 ;;
[37255]168 vboxwebsrv)
[48787]169 exec "$INSTALL_DIR/vboxwebsrv" "$@"
[37255]170 ;;
171 *)
172 echo "Unknown application - $APP"
173 exit 1
174 ;;
[4050]175esac
[37255]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