VirtualBox

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

Last change on this file since 44940 was 44674, checked in by vboxsync, 12 years ago

Installer/linux: no need to have two different versions of VBox.sh.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1#!/bin/sh
2#
3# Oracle VM VirtualBox startup script, Linux hosts.
4#
5# Copyright (C) 2006-2012 Oracle Corporation
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 (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15
16PATH="/usr/bin:/bin:/usr/sbin:/sbin"
17CONFIG="/etc/vbox/vbox.cfg"
18
19if test -r "${CONFIG}"; then
20 . "${CONFIG}"
21elif test -f /usr/lib/virtualbox/VirtualBox &&
22 test -x /usr/lib/virtualbox/VirtualBox; then
23 INSTALL_DIR=/usr/lib/virtualbox
24else
25 echo "Could not find VirtualBox installation. Please reinstall."
26 exit 1
27fi
28
29# Note: This script must not fail if the module was not successfully installed
30# because the user might not want to run a VM but only change VM params!
31
32if [ "$1" = "shutdown" ]; then
33 SHUTDOWN="true"
34elif ! lsmod|grep -q vboxdrv; then
35 cat << EOF
36WARNING: The vboxdrv kernel module is not loaded. Either there is no module
37 available for the current kernel (`uname -r`) or it failed to
38 load. Please recompile the kernel module and install it by
39
40 sudo /etc/init.d/vboxdrv setup
41
42 You will not be able to start VMs until this problem is fixed.
43EOF
44elif [ ! -c /dev/vboxdrv ]; then
45 cat << EOF
46WARNING: The character device /dev/vboxdrv does not exist. Try
47
48 sudo /etc/init.d/vboxdrv restart
49
50 and if that is not successful, try to re-install the package.
51
52 You will not be able to start VMs until this problem is fixed.
53EOF
54fi
55
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
64SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
65if [ -z "$SERVER_PID" ]; then
66 # Server not running yet/anymore, cleanup socket path.
67 # See IPC_GetDefaultSocketPath()!
68 if [ -n "$LOGNAME" ]; then
69 rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
70 else
71 rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
72 fi
73fi
74
75if [ "$SHUTDOWN" = "true" ]; then
76 if [ -n "$SERVER_PID" ]; then
77 kill -TERM $SERVER_PID
78 sleep 2
79 fi
80 exit 0
81fi
82
83run_in_group()
84{
85 if id -G -n $(id -u -n) | tr ' ' '\n' | grep -q "vboxusers"; then
86 AWK_SCRIPT='BEGIN { for ( i=1; i < ARGC; i++) {gsub(/'\''/, "'\''\\'\''", ARGV[i]); printf "'\''%s'\'' ", ARGV[i]}}'
87 AWK_SCRIPT="BEGIN { for ( i=1; i < ARGC; i++) {gsub(/'/, \"'\\\\'\", ARGV[i]); printf \"'%s' \", ARGV[i]}}"
88 ARGS="$(awk "$AWK_SCRIPT" "$@")"
89 echo ${ARGS} ";" "exit" | exec newgrp vboxusers
90 else
91 exec "$@"
92 fi
93}
94
95APP=`basename $0`
96case "$APP" in
97 VirtualBox|virtualbox)
98 run_in_group "$INSTALL_DIR/VirtualBox" "$@"
99 ;;
100 VBoxManage|vboxmanage)
101 run_in_group "$INSTALL_DIR/VBoxManage" "$@"
102 ;;
103 VBoxSDL|vboxsdl)
104 run_in_group "$INSTALL_DIR/VBoxSDL" "$@"
105 ;;
106 VBoxVRDP|VBoxHeadless|vboxheadless)
107 run_in_group "$INSTALL_DIR/VBoxHeadless" "$@"
108 ;;
109 VBoxAutostart|vboxautostart)
110 run_in_group "$INSTALL_DIR/VBoxAutostart" "$@"
111 ;;
112 VBoxBalloonCtrl|vboxballoonctrl)
113 run_in_group "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
114 ;;
115 vboxwebsrv)
116 run_in_group "$INSTALL_DIR/vboxwebsrv" "$@"
117 ;;
118 *)
119 echo "Unknown application - $APP"
120 exit 1
121 ;;
122esac
123exit 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