1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | # Sun VirtualBox
|
---|
4 | # VirtualBox IPS/pkg(5) postinstall script for Solaris.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | # additional information or have any questions.
|
---|
21 | #
|
---|
22 |
|
---|
23 | #
|
---|
24 | # If you just installed VirtualBox using IPS/pkg(5), you should run this
|
---|
25 | # script once to avoid rebooting the system before using VirtualBox
|
---|
26 | #
|
---|
27 |
|
---|
28 | check_root()
|
---|
29 | {
|
---|
30 | idbin=/usr/xpg4/bin/id
|
---|
31 | if test ! -f "$idbin"; then
|
---|
32 | found=`which id | grep "no id"`
|
---|
33 | if test ! -z "$found"; then
|
---|
34 | echo "## Failed to find a suitable user id binary."
|
---|
35 | else
|
---|
36 | idbin=$found
|
---|
37 | fi
|
---|
38 | fi
|
---|
39 |
|
---|
40 | if test `$idbin -u` -ne 0; then
|
---|
41 | echo "## This script must be run with administrator privileges."
|
---|
42 | fi
|
---|
43 | }
|
---|
44 |
|
---|
45 | check_zone()
|
---|
46 | {
|
---|
47 | currentzone=`zonename`
|
---|
48 | if test "$currentzone" != "global"; then
|
---|
49 | echo "## This script must be run from the global zone."
|
---|
50 | fi
|
---|
51 | }
|
---|
52 |
|
---|
53 | check_root
|
---|
54 | check_zone
|
---|
55 |
|
---|
56 | osversion=`uname -r`
|
---|
57 |
|
---|
58 | BIN_REMDRV=/usr/sbin/rem_drv
|
---|
59 | BIN_ADDDRV=/usr/sbin/add_drv
|
---|
60 | BIN_MODLOAD=/usr/sbin/modload
|
---|
61 | BIN_DEVFSADM=/usr/sbin/devfsadm
|
---|
62 |
|
---|
63 | # Halt services in case of installation update
|
---|
64 | zoneaccessfound=`svcs -a | grep "virtualbox/zoneaccess"`
|
---|
65 | if test ! -z "$zoneaccessfound"; then
|
---|
66 | /usr/sbin/svcadm disable -s svc:/application/virtualbox/zoneaccess
|
---|
67 | fi
|
---|
68 |
|
---|
69 | # Remove drivers ignoring errors as they are not really loaded
|
---|
70 | # just updated various boot archive files without really loading
|
---|
71 | # them... But we _want_ them to be loaded.
|
---|
72 | echo "Removing any stale driver configurations..."
|
---|
73 |
|
---|
74 | $BIN_REMDRV vboxflt > /dev/null 2>&1
|
---|
75 | /sbin/ifconfig vboxnet0 unplumb > /dev/null 2>&1
|
---|
76 | $BIN_REMDRV vboxnet > /dev/null 2>&1
|
---|
77 | $BIN_REMDRV vboxusbmon > /dev/null 2>&1
|
---|
78 | $BIN_REMDRV vboxdrv > /dev/null 2>&1
|
---|
79 |
|
---|
80 | echo "Loading VirtualBox Drivers:"
|
---|
81 | # Add drivers the proper way and load them immediately
|
---|
82 | /opt/VirtualBox/vboxdrv.sh start
|
---|
83 | rc=$?
|
---|
84 | if test "$rc" -eq 0; then
|
---|
85 | # Add vboxdrv to the devlink.tab
|
---|
86 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
87 | echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
|
---|
88 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
89 |
|
---|
90 | # Create the device link
|
---|
91 | /usr/sbin/devfsadm -i vboxdrv
|
---|
92 |
|
---|
93 | echo "HostDrv : SUCCESS"
|
---|
94 |
|
---|
95 | # Load VBoxNetAdapter vboxnet
|
---|
96 | if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
|
---|
97 | /opt/VirtualBox/vboxdrv.sh netstart
|
---|
98 | rc=$?
|
---|
99 |
|
---|
100 | if test "$rc" -eq 0; then
|
---|
101 | echo "NetAdapter : SUCCESS"
|
---|
102 |
|
---|
103 | # nwam/dhcpagent fix
|
---|
104 | nwamfile=/etc/nwam/llp
|
---|
105 | nwambackupfile=$nwamfile.vbox
|
---|
106 | if test -f "$nwamfile"; then
|
---|
107 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
108 | echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
|
---|
109 | mv -f $nwambackupfile $nwamfile
|
---|
110 | echo " -> patched /etc/nwam/llp to use static IP for vboxnet0"
|
---|
111 | fi
|
---|
112 | else
|
---|
113 | echo "NetAdapter : FAILED"
|
---|
114 | fi
|
---|
115 | fi
|
---|
116 |
|
---|
117 | # Load VBoxNetFilter vboxflt
|
---|
118 | if test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
|
---|
119 | /opt/VirtualBox/vboxdrv.sh fltstart
|
---|
120 | rc=$?
|
---|
121 | if test "$rc" -eq 0; then
|
---|
122 | echo "NetFilter : SUCCESS"
|
---|
123 | else
|
---|
124 | echo "NetFilter : FAILED"
|
---|
125 | fi
|
---|
126 | fi
|
---|
127 |
|
---|
128 | # Load VBoxUSBMonitor vboxusbmon (do NOT load for Solaris 10)
|
---|
129 | if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$osversion" != "5.10"; then
|
---|
130 | /opt/VirtualBox/vboxdrv.sh usbstart
|
---|
131 | rc=$?
|
---|
132 | if test "$rc" -eq 0; then
|
---|
133 |
|
---|
134 | # Add vboxusbmon to the devlink.tab
|
---|
135 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
136 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
|
---|
137 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
138 |
|
---|
139 | /usr/sbin/devfsadm -i vboxusbmon
|
---|
140 |
|
---|
141 | echo "USBMonitor : SUCCESS"
|
---|
142 | else
|
---|
143 | echo "USBMonitor : FAILED"
|
---|
144 | fi
|
---|
145 | fi
|
---|
146 | else
|
---|
147 | echo "HostDrv : FAILED"
|
---|
148 | fi
|
---|
149 |
|
---|
150 | # Enable Zone access service
|
---|
151 | if test -f /var/svc/manifest/application/virtualbox/zoneaccess.xml; then
|
---|
152 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
153 | echo "Service to use VirtualBox from zones : ENABLED"
|
---|
154 | fi
|
---|
155 |
|
---|
156 | # We need to touch the desktop link in order to add it to the menu right away
|
---|
157 | if test -f "/usr/share/applications/virtualbox.desktop"; then
|
---|
158 | touch /usr/share/applications/virtualbox.desktop
|
---|
159 | fi
|
---|
160 |
|
---|
161 | # Install python bindings
|
---|
162 | if test -f "/opt/VirtualBox/sdk/installer/vboxapisetup.py" || test -h "/opt/VirtualBox/sdk/installer/vboxapisetup.py"; then
|
---|
163 | PYTHONBIN=`which python`
|
---|
164 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
165 | echo "Installing Python bindings..."
|
---|
166 |
|
---|
167 | VBOX_INSTALL_PATH=/opt/VirtualBox
|
---|
168 | export VBOX_INSTALL_PATH
|
---|
169 | cd /opt/VirtualBox/sdk/installer
|
---|
170 | $PYTHONBIN ./vboxapisetup.py install > /dev/null
|
---|
171 | else
|
---|
172 | echo "** WARNING! Python not found, skipped installed Python bindings."
|
---|
173 | echo " Manually run '/opt/VirtualBox/sdk/installer/vboxapisetup.py install'"
|
---|
174 | echo " to install the bindings when python is available."
|
---|
175 | fi
|
---|
176 | fi
|
---|
177 |
|
---|
178 | # Update boot archive
|
---|
179 | BOOTADMBIN=/sbin/bootadm
|
---|
180 | if test -f "$BOOTADMBIN" || test -h "$BOOTADMBIN"; then
|
---|
181 | echo "Updating boot archive..."
|
---|
182 | $BOOTADMBIN update-archive > /dev/null
|
---|
183 | fi
|
---|
184 |
|
---|
185 | echo "Done."
|
---|
186 |
|
---|
187 | exit 0
|
---|
188 |
|
---|