1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | # Sun VirtualBox - Manual IPS/pkg(5) postinstall script for Solaris.
|
---|
4 | #
|
---|
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.
|
---|
7 | #
|
---|
8 |
|
---|
9 | #
|
---|
10 | # Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
11 | #
|
---|
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.
|
---|
19 | #
|
---|
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.
|
---|
23 | #
|
---|
24 |
|
---|
25 | check_root()
|
---|
26 | {
|
---|
27 | idbin=/usr/xpg4/bin/id
|
---|
28 | if test ! -f "$idbin"; then
|
---|
29 | found=`which id | grep "no id"`
|
---|
30 | if test ! -z "$found"; then
|
---|
31 | echo "## Failed to find a suitable user id binary."
|
---|
32 | exit 1
|
---|
33 | else
|
---|
34 | idbin=$found
|
---|
35 | fi
|
---|
36 | fi
|
---|
37 |
|
---|
38 | if test `$idbin -u` -ne 0; then
|
---|
39 | echo "## This script must be run with administrator privileges."
|
---|
40 | exit 2
|
---|
41 | fi
|
---|
42 | }
|
---|
43 |
|
---|
44 | check_zone()
|
---|
45 | {
|
---|
46 | currentzone=`zonename`
|
---|
47 | if test "$currentzone" != "global"; then
|
---|
48 | echo "## This script must be run from the global zone."
|
---|
49 | exit 3
|
---|
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 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 | rc=$?
|
---|
93 |
|
---|
94 | if test "$rc" -eq 0; then
|
---|
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 | # nwam/dhcpagent fix
|
---|
102 | nwamfile=/etc/nwam/llp
|
---|
103 | nwambackupfile=$nwamfile.vbox
|
---|
104 | if test -f "$nwamfile"; then
|
---|
105 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
106 | echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
|
---|
107 | mv -f $nwambackupfile $nwamfile
|
---|
108 | echo " -> patched /etc/nwam/llp to use static IP for vboxnet0"
|
---|
109 | fi
|
---|
110 | fi
|
---|
111 | fi
|
---|
112 | else
|
---|
113 | echo "## Failed to create device link in /dev for vboxdrv"
|
---|
114 | fi
|
---|
115 |
|
---|
116 | # Load VBoxNetFilter vboxflt
|
---|
117 | if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
|
---|
118 | /opt/VirtualBox/vboxdrv.sh fltstart
|
---|
119 | rc=$?
|
---|
120 | fi
|
---|
121 |
|
---|
122 | # Load VBoxUSBMonitor vboxusbmon (do NOT load for Solaris 10)
|
---|
123 | if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$osversion" != "5.10"; then
|
---|
124 | /opt/VirtualBox/vboxdrv.sh usbstart
|
---|
125 | rc=$?
|
---|
126 | if test "$rc" -eq 0; then
|
---|
127 |
|
---|
128 | # Add vboxusbmon to the devlink.tab
|
---|
129 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
130 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
|
---|
131 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
132 |
|
---|
133 | /usr/sbin/devfsadm -i vboxusbmon
|
---|
134 | rc=$?
|
---|
135 | if test "$rc" -ne 0; then
|
---|
136 | echo "## Failed to create device link in /dev for vboxusbmon"
|
---|
137 | fi
|
---|
138 | fi
|
---|
139 | fi
|
---|
140 | fi
|
---|
141 |
|
---|
142 | rc2=0
|
---|
143 | # Enable Zone access service (note IPS auto-prefixes "virtualbox-" to the filename...)
|
---|
144 | if test -f "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
|
---|
145 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
|
---|
146 | rc2=$?
|
---|
147 | if test "$rc2" -eq 0; then
|
---|
148 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
149 | rc2=$?
|
---|
150 | if test "$rc2" -eq 0; then
|
---|
151 | echo "Enabled VirtualBox zone service."
|
---|
152 | else
|
---|
153 | echo "## Failed to enable VirtualBox zone service."
|
---|
154 | fi
|
---|
155 | else
|
---|
156 | echo "## Failed to import VirtualBox zone service."
|
---|
157 | fi
|
---|
158 | fi
|
---|
159 |
|
---|
160 | # We need to touch the desktop link in order to add it to the menu right away
|
---|
161 | if test -f "/usr/share/applications/virtualbox.desktop"; then
|
---|
162 | touch /usr/share/applications/virtualbox.desktop
|
---|
163 | echo "Added VirtualBox shortcut menu item."
|
---|
164 | fi
|
---|
165 |
|
---|
166 | # Install python bindings
|
---|
167 | rc3=0
|
---|
168 | if test -f "/opt/VirtualBox/sdk/installer/vboxapisetup.py" || test -h "/opt/VirtualBox/sdk/installer/vboxapisetup.py"; then
|
---|
169 | PYTHONBIN=`which python`
|
---|
170 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
171 | echo "Installing python bindings..."
|
---|
172 |
|
---|
173 | VBOX_INSTALL_PATH=/opt/VirtualBox
|
---|
174 | export VBOX_INSTALL_PATH
|
---|
175 | cd /opt/VirtualBox/sdk/installer
|
---|
176 | $PYTHONBIN ./vboxapisetup.py install > /dev/null
|
---|
177 | rc3=$?
|
---|
178 | echo "Done."
|
---|
179 | else
|
---|
180 | echo "** WARNING! Python not found, skipped installed Python bindings."
|
---|
181 | echo " Manually run '/opt/VirtualBox/sdk/installer/vboxapisetup.py install'"
|
---|
182 | echo " to install the bindings when python is available."
|
---|
183 | rc3=1
|
---|
184 | fi
|
---|
185 | fi
|
---|
186 |
|
---|
187 | # Update boot archive (only when driver's were all successfully loaded)
|
---|
188 | rc4=0
|
---|
189 | if test "$rc" -eq 0; then
|
---|
190 | BOOTADMBIN=/sbin/bootadm
|
---|
191 | if test -f "$BOOTADMBIN" || test -h "$BOOTADMBIN"; then
|
---|
192 | echo "Updating boot archive..."
|
---|
193 | $BOOTADMBIN update-archive > /dev/null
|
---|
194 | rc4=$?
|
---|
195 | fi
|
---|
196 | fi
|
---|
197 |
|
---|
198 | echo "Done."
|
---|
199 | if test "$rc" -eq 0 && test "$rc2" -eq 0 && test "$rc3" -eq 0 && test "$rc4" -eq 0; then
|
---|
200 | echo "Post install successfully completed."
|
---|
201 | else
|
---|
202 | echo "Post install completed but with some errors."
|
---|
203 | # 20 - partially failed installed
|
---|
204 | $rc=20
|
---|
205 | fi
|
---|
206 | exit $rc
|
---|
207 |
|
---|