VirtualBox

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

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