3
# Sun VirtualBox - Manual IPS/pkg(5) postinstall script for Solaris.
5
# If you just installed VirtualBox using IPS/pkg(5), you should run this
6
# script once to avoid rebooting the system before using VirtualBox.
10
# Copyright (C) 2009 Sun Microsystems, Inc.
12
# This file is part of VirtualBox Open Source Edition (OSE), as
13
# available from http://www.virtualbox.org. This file is free software;
14
# you can redistribute it and/or modify it under the terms of the GNU
15
# General Public License (GPL) as published by the Free Software
16
# Foundation, in version 2 as it comes in the "COPYING" file of the
17
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21
# Clara, CA 95054 USA or visit http://www.sun.com if you need
22
# additional information or have any questions.
27
idbin=/usr/xpg4/bin/id
28
if test ! -f "$idbin"; then
30
if test ! -f "$found" || test ! -h "$found"; then
31
echo "## Failed to find a suitable user id binary."
38
if test `$idbin -u` -ne 0; then
39
echo "## This script must be run with administrator privileges."
46
currentzone=`zonename`
47
if test "$currentzone" != "global"; then
48
echo "## This script must be run from the global zone."
53
install_python_bindings()
56
if test -x "$PYTHONBIN"; then
57
VBOX_INSTALL_PATH=/opt/VirtualBox
58
export VBOX_INSTALL_PATH
59
cd /opt/VirtualBox/sdk/installer
60
$PYTHONBIN ./vboxapisetup.py install > /dev/null
71
BIN_REMDRV=/usr/sbin/rem_drv
72
BIN_ADDDRV=/usr/sbin/add_drv
73
BIN_MODLOAD=/usr/sbin/modload
74
BIN_DEVFSADM=/usr/sbin/devfsadm
76
# Halt services in case of installation update
77
zoneaccessfound=`svcs -a | grep "virtualbox/zoneaccess"`
78
if test ! -z "$zoneaccessfound"; then
79
/usr/sbin/svcadm disable -s svc:/application/virtualbox/zoneaccess
82
# Remove drivers ignoring errors as they are not really loaded
83
# just updated various boot archive files without really loading
84
# them... But we _want_ them to be loaded.
85
echo "Removing stale driver configurations..."
87
$BIN_REMDRV vboxflt > /dev/null 2>&1
88
/sbin/ifconfig vboxnet0 unplumb > /dev/null 2>&1
89
$BIN_REMDRV vboxnet > /dev/null 2>&1
90
$BIN_REMDRV vboxusbmon > /dev/null 2>&1
91
$BIN_REMDRV vboxdrv > /dev/null 2>&1
93
echo "Loading VirtualBox Drivers:"
94
# Add drivers the proper way and load them immediately
95
/opt/VirtualBox/vboxdrv.sh start
97
if test "$rc" -eq 0; then
98
# Add vboxdrv to the devlink.tab
99
sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
100
echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
101
mv -f /etc/devlink.vbox /etc/devlink.tab
103
# Create the device link
104
/usr/sbin/devfsadm -i vboxdrv
107
if test "$rc" -eq 0; then
108
# Load VBoxNetAdapter vboxnet
109
if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
110
/opt/VirtualBox/vboxdrv.sh netstart
113
if test "$rc" -eq 0; then
115
nwamfile=/etc/nwam/llp
116
nwambackupfile=$nwamfile.vbox
117
if test -f "$nwamfile"; then
118
sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
119
echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
120
mv -f $nwambackupfile $nwamfile
121
echo " -> patched /etc/nwam/llp to use static IP for vboxnet0"
126
echo "## Failed to create device link in /dev for vboxdrv"
129
# Load VBoxNetFilter vboxflt
130
if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
131
/opt/VirtualBox/vboxdrv.sh fltstart
135
# Load VBoxUSBMonitor vboxusbmon (do NOT load for Solaris 10)
136
if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$osversion" != "5.10"; then
137
/opt/VirtualBox/vboxdrv.sh usbstart
139
if test "$rc" -eq 0; then
141
# Add vboxusbmon to the devlink.tab
142
sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
143
echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
144
mv -f /etc/devlink.vbox /etc/devlink.tab
146
/usr/sbin/devfsadm -i vboxusbmon
148
if test "$rc" -ne 0; then
149
echo "## Failed to create device link in /dev for vboxusbmon"
156
if test -f "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
157
/usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
159
if test "$rc2" -eq 0; then
160
/usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
162
if test "$rc2" -eq 0; then
163
echo "Enabled VirtualBox zone service."
165
echo "## Failed to enable VirtualBox zone service."
168
echo "## Failed to import VirtualBox zone service."
172
# We need to touch the desktop link in order to add it to the menu right away
173
if test -f "/usr/share/applications/virtualbox.desktop"; then
174
touch /usr/share/applications/virtualbox.desktop
175
echo "Added VirtualBox shortcut menu item."
178
# Install python bindings
180
if test -f "/opt/VirtualBox/sdk/installer/vboxapisetup.py" || test -h "/opt/VirtualBox/sdk/installer/vboxapisetup.py"; then
181
PYTHONBIN=`which python`
182
if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
183
echo "Installing Python bindings..."
186
PYTHONBIN=`which python2.4`
187
install_python_bindings "$PYTHONBIN"
188
if test "$?" -eq 0; then
191
PYTHONBIN=`which python2.5`
192
install_python_bindings "$PYTHONBIN"
193
if test "$?" -eq 0; then
196
PYTHONBIN=`which python2.6`
197
install_python_bindings "$PYTHONBIN"
198
if test "$?" -eq 0; then
202
# remove files installed by Python build
203
rm -rf /opt/VirtualBox/sdk/installer/build
205
if test "$INSTALLEDIT" -ne 0; then
206
echo "** No suitable Python version found. Requires Python 2.4, 2.5 or 2.6."
210
echo "** WARNING! Python not found, skipped installed Python bindings."
211
echo " Manually run '/opt/VirtualBox/sdk/installer/vboxapisetup.py install'"
212
echo " to install the bindings when python is available."
217
# Update boot archive (only when driver's were all successfully loaded)
219
if test "$rc" -eq 0; then
220
BOOTADMBIN=/sbin/bootadm
221
if test -f "$BOOTADMBIN" || test -h "$BOOTADMBIN"; then
222
echo "Updating boot archive..."
223
$BOOTADMBIN update-archive > /dev/null
229
if test "$rc" -eq 0 && test "$rc2" -eq 0 && test "$rc3" -eq 0 && test "$rc4" -eq 0; then
230
echo "Post install successfully completed."
232
echo "Post install completed but with some errors."
233
# 20 - partially failed installed