1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # VirtualBox Configuration Script, Solaris host.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox base platform packages, as
|
---|
11 | # available from https://www.virtualbox.org.
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or
|
---|
14 | # modify it under the terms of the GNU General Public License
|
---|
15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
16 | # License.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful, but
|
---|
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | # General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | #
|
---|
26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | #
|
---|
28 |
|
---|
29 | # Never use exit 2 or exit 20 etc., the return codes are used in
|
---|
30 | # SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
|
---|
31 |
|
---|
32 | # LC_ALL should take precedence over LC_* and LANG but whatever...
|
---|
33 | LC_ALL=C
|
---|
34 | export LC_ALL
|
---|
35 |
|
---|
36 | LANG=C
|
---|
37 | export LANG
|
---|
38 |
|
---|
39 | VBOX_INSTALL_PATH="$PKG_INSTALL_ROOT/opt/VirtualBox"
|
---|
40 | CONFIG_DIR=/etc/vbox
|
---|
41 | CONFIG_FILES=filelist
|
---|
42 | DIR_CONF="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
|
---|
43 | DIR_MOD_32="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
|
---|
44 | DIR_MOD_64="$DIR_MOD_32/amd64"
|
---|
45 |
|
---|
46 | # Default paths, these will be overridden by 'which' if they don't exist
|
---|
47 | BIN_ADDDRV=/usr/sbin/add_drv
|
---|
48 | BIN_REMDRV=/usr/sbin/rem_drv
|
---|
49 | BIN_MODLOAD=/usr/sbin/modload
|
---|
50 | BIN_MODUNLOAD=/usr/sbin/modunload
|
---|
51 | BIN_MODINFO=/usr/sbin/modinfo
|
---|
52 | BIN_DEVFSADM=/usr/sbin/devfsadm
|
---|
53 | BIN_BOOTADM=/sbin/bootadm
|
---|
54 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
55 | BIN_SVCCFG=/usr/sbin/svccfg
|
---|
56 | BIN_SVCS=/usr/bin/svcs
|
---|
57 | BIN_IFCONFIG=/sbin/ifconfig
|
---|
58 | BIN_SVCS=/usr/bin/svcs
|
---|
59 | BIN_ID=/usr/bin/id
|
---|
60 | BIN_PKILL=/usr/bin/pkill
|
---|
61 | BIN_PGREP=/usr/bin/pgrep
|
---|
62 | BIN_IPADM=/usr/sbin/ipadm
|
---|
63 |
|
---|
64 | # "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
|
---|
65 | MOD_VBOXDRV=vboxdrv
|
---|
66 | DESC_VBOXDRV="Host"
|
---|
67 |
|
---|
68 | MOD_VBOXNET=vboxnet
|
---|
69 | DESC_VBOXNET="NetAdapter"
|
---|
70 | MOD_VBOXNET_INST=8
|
---|
71 |
|
---|
72 | MOD_VBOXFLT=vboxflt
|
---|
73 | DESC_VBOXFLT="NetFilter (STREAMS)"
|
---|
74 |
|
---|
75 | MOD_VBOXBOW=vboxbow
|
---|
76 | DESC_VBOXBOW="NetFilter (Crossbow)"
|
---|
77 |
|
---|
78 | MOD_VBOXUSBMON=vboxusbmon
|
---|
79 | DESC_VBOXUSBMON="USBMonitor"
|
---|
80 |
|
---|
81 | MOD_VBOXUSB=vboxusb
|
---|
82 | DESC_VBOXUSB="USB"
|
---|
83 |
|
---|
84 | UPDATEBOOTARCHIVE=0
|
---|
85 | REMOTEINST=0
|
---|
86 | FATALOP=fatal
|
---|
87 | NULLOP=nulloutput
|
---|
88 | SILENTOP=silent
|
---|
89 | IPSOP=ips
|
---|
90 | ISSILENT=
|
---|
91 | ISIPS=
|
---|
92 |
|
---|
93 | infoprint()
|
---|
94 | {
|
---|
95 | if test "x$ISSILENT" != "x$SILENTOP"; then
|
---|
96 | echo 1>&2 "$1"
|
---|
97 | fi
|
---|
98 | }
|
---|
99 |
|
---|
100 | subprint()
|
---|
101 | {
|
---|
102 | if test "x$ISSILENT" != "x$SILENTOP"; then
|
---|
103 | echo 1>&2 " - $1"
|
---|
104 | fi
|
---|
105 | }
|
---|
106 |
|
---|
107 | warnprint()
|
---|
108 | {
|
---|
109 | if test "x$ISSILENT" != "x$SILENTOP"; then
|
---|
110 | echo 1>&2 " * Warning!! $1"
|
---|
111 | fi
|
---|
112 | }
|
---|
113 |
|
---|
114 | errorprint()
|
---|
115 | {
|
---|
116 | echo 1>&2 "## $1"
|
---|
117 | }
|
---|
118 |
|
---|
119 | helpprint()
|
---|
120 | {
|
---|
121 | echo 1>&2 "$1"
|
---|
122 | }
|
---|
123 |
|
---|
124 | printusage()
|
---|
125 | {
|
---|
126 | helpprint "VirtualBox Configuration Script"
|
---|
127 | helpprint "usage: $0 <operation> [options]"
|
---|
128 | helpprint
|
---|
129 | helpprint "<operation> must be one of the following:"
|
---|
130 | helpprint " --postinstall Perform full post installation procedure"
|
---|
131 | helpprint " --preremove Perform full pre remove procedure"
|
---|
132 | helpprint " --installdrivers Only install the drivers"
|
---|
133 | helpprint " --removedrivers Only remove the drivers"
|
---|
134 | helpprint " --setupdrivers Setup drivers, reloads existing drivers"
|
---|
135 | helpprint
|
---|
136 | helpprint "[options] are one or more of the following:"
|
---|
137 | helpprint " --silent Silent mode"
|
---|
138 | helpprint " --fatal Don't continue on failure (required for postinstall)"
|
---|
139 | helpprint " --ips This is an IPS package postinstall/preremove"
|
---|
140 | helpprint " --altkerndir Use /usr/kernel/drv as the driver directory"
|
---|
141 | helpprint
|
---|
142 | }
|
---|
143 |
|
---|
144 | # find_bin_path()
|
---|
145 | # !! failure is always fatal
|
---|
146 | find_bin_path()
|
---|
147 | {
|
---|
148 | if test -z "$1"; then
|
---|
149 | errorprint "missing argument to find_bin_path()"
|
---|
150 | exit 1
|
---|
151 | fi
|
---|
152 |
|
---|
153 | binfilename=`basename $1`
|
---|
154 | binfilepath=`which $binfilename 2> /dev/null`
|
---|
155 | if test -x "$binfilepath"; then
|
---|
156 | echo "$binfilepath"
|
---|
157 | return 0
|
---|
158 | else
|
---|
159 | errorprint "$1 missing or is not an executable"
|
---|
160 | exit 1
|
---|
161 | fi
|
---|
162 | }
|
---|
163 |
|
---|
164 | # find_bins()
|
---|
165 | # !! failure is always fatal
|
---|
166 | find_bins()
|
---|
167 | {
|
---|
168 | # Search only for binaries that might be in different locations
|
---|
169 | if test ! -x "$BIN_ID"; then
|
---|
170 | BIN_ID=`find_bin_path "$BIN_ID"`
|
---|
171 | fi
|
---|
172 |
|
---|
173 | if test ! -x "$BIN_ADDDRV"; then
|
---|
174 | BIN_ADDDRV=`find_bin_path "$BIN_ADDDRV"`
|
---|
175 | fi
|
---|
176 |
|
---|
177 | if test ! -x "$BIN_REMDRV"; then
|
---|
178 | BIN_REMDRV=`find_bin_path "$BIN_REMDRV"`
|
---|
179 | fi
|
---|
180 |
|
---|
181 | if test ! -x "$BIN_MODLOAD"; then
|
---|
182 | BIN_MODLOAD=`check_bin_path "$BIN_MODLOAD"`
|
---|
183 | fi
|
---|
184 |
|
---|
185 | if test ! -x "$BIN_MODUNLOAD"; then
|
---|
186 | BIN_MODUNLOAD=`find_bin_path "$BIN_MODUNLOAD"`
|
---|
187 | fi
|
---|
188 |
|
---|
189 | if test ! -x "$BIN_MODINFO"; then
|
---|
190 | BIN_MODINFO=`find_bin_path "$BIN_MODINFO"`
|
---|
191 | fi
|
---|
192 |
|
---|
193 | if test ! -x "$BIN_DEVFSADM"; then
|
---|
194 | BIN_DEVFSADM=`find_bin_path "$BIN_DEVFSADM"`
|
---|
195 | fi
|
---|
196 |
|
---|
197 | if test ! -x "$BIN_BOOTADM"; then
|
---|
198 | BIN_BOOTADM=`find_bin_path "$BIN_BOOTADM"`
|
---|
199 | fi
|
---|
200 |
|
---|
201 | if test ! -x "$BIN_SVCADM"; then
|
---|
202 | BIN_SVCADM=`find_bin_path "$BIN_SVCADM"`
|
---|
203 | fi
|
---|
204 |
|
---|
205 | if test ! -x "$BIN_SVCCFG"; then
|
---|
206 | BIN_SVCCFG=`find_bin_path "$BIN_SVCCFG"`
|
---|
207 | fi
|
---|
208 |
|
---|
209 | if test ! -x "$BIN_SVCS"; then
|
---|
210 | BIN_SVCS=`find_bin_path "$BIN_SVCS"`
|
---|
211 | fi
|
---|
212 |
|
---|
213 | if test ! -x "$BIN_IFCONFIG"; then
|
---|
214 | BIN_IFCONFIG=`find_bin_path "$BIN_IFCONFIG"`
|
---|
215 | fi
|
---|
216 |
|
---|
217 | if test ! -x "$BIN_PKILL"; then
|
---|
218 | BIN_PKILL=`find_bin_path "$BIN_PKILL"`
|
---|
219 | fi
|
---|
220 |
|
---|
221 | if test ! -x "$BIN_PGREP"; then
|
---|
222 | BIN_PGREP=`find_bin_path "$BIN_PGREP"`
|
---|
223 | fi
|
---|
224 |
|
---|
225 | if test ! -x "$BIN_IPADM"; then
|
---|
226 | BIN_IPADM=`find_bin_path "$BIN_IPADM"`
|
---|
227 | fi
|
---|
228 | }
|
---|
229 |
|
---|
230 | # check_root()
|
---|
231 | # !! failure is always fatal
|
---|
232 | check_root()
|
---|
233 | {
|
---|
234 | # Don't use "-u" option as some id binaries don't support it, instead
|
---|
235 | # rely on "uid=101(username) gid=10(groupname) groups=10(staff)" output
|
---|
236 | curuid=`$BIN_ID | cut -f 2 -d '=' | cut -f 1 -d '('`
|
---|
237 | if test "$curuid" -ne 0; then
|
---|
238 | errorprint "This script must be run with administrator privileges."
|
---|
239 | exit 1
|
---|
240 | fi
|
---|
241 | }
|
---|
242 |
|
---|
243 | # get_unofficial_sysinfo()
|
---|
244 | # cannot fail
|
---|
245 | get_unofficial_sysinfo()
|
---|
246 | {
|
---|
247 | HOST_OS_MAJORVERSION="11"
|
---|
248 | HOST_OS_MINORVERSION="151"
|
---|
249 | }
|
---|
250 |
|
---|
251 | # get_s11_4_sysinfo()
|
---|
252 | # cannot fail
|
---|
253 | get_s11_4_sysinfo()
|
---|
254 | {
|
---|
255 | # See check in plumb_net for why this is > 174. The alternative is we declare 11.4+ as S12 with
|
---|
256 | # a more accurate minor (build) version number. For now this is sufficient to workaround the ever
|
---|
257 | # changing version numbering policy.
|
---|
258 | HOST_OS_MAJORVERSION="11"
|
---|
259 | HOST_OS_MINORVERSION="175"
|
---|
260 | }
|
---|
261 |
|
---|
262 | # get_s11_5_or_newer_sysinfo()
|
---|
263 | # cannot fail
|
---|
264 | get_s11_5_or_newer_sysinfo()
|
---|
265 | {
|
---|
266 | # See check in plumb_net for why this is 176.
|
---|
267 | HOST_OS_MAJORVERSION="11"
|
---|
268 | HOST_OS_MINORVERSION="176"
|
---|
269 | }
|
---|
270 |
|
---|
271 | # get_sysinfo()
|
---|
272 | # cannot fail
|
---|
273 | get_sysinfo()
|
---|
274 | {
|
---|
275 | STR_OSVER=`uname -v`
|
---|
276 | case "$STR_OSVER" in
|
---|
277 | # First check 'uname -v' and weed out the recognized, unofficial distros of Solaris
|
---|
278 | omnios*|oi_*|illumos*)
|
---|
279 | get_unofficial_sysinfo
|
---|
280 | return 0
|
---|
281 | ;;
|
---|
282 | # Quick escape workaround for Solaris 11.4, changes the pkg FMRI (yet again). See BugDB #26494983.
|
---|
283 | 11.4.*)
|
---|
284 | get_s11_4_sysinfo
|
---|
285 | return 0
|
---|
286 | ;;
|
---|
287 | # Quick escape workaround for Solaris 11.5. See BugDB #26494983.
|
---|
288 | 11.5.*)
|
---|
289 | get_s11_5_or_newer_sysinfo
|
---|
290 | return 0
|
---|
291 | esac
|
---|
292 |
|
---|
293 | BIN_PKG=`which pkg 2> /dev/null`
|
---|
294 | if test -x "$BIN_PKG"; then
|
---|
295 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -a name=pkg.fmri -o pkg.fmri pkg:/system/kernel 2> /dev/null`
|
---|
296 | if test -z "$PKGFMRI"; then
|
---|
297 | # Perhaps this is old pkg without '-a' option and/or system/kernel is missing and it's part of 'entire'
|
---|
298 | # Try fallback.
|
---|
299 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -o pkg.fmri entire | head -1 2> /dev/null`
|
---|
300 | if test -z "$PKGFMRI"; then
|
---|
301 | # Perhaps entire is conflicting. Try using opensolaris/entire.
|
---|
302 | # Last fallback try.
|
---|
303 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -o pkg.fmri opensolaris.org/entire | head -1 2> /dev/null`
|
---|
304 | fi
|
---|
305 | fi
|
---|
306 | if test ! -z "$PKGFMRI"; then
|
---|
307 | # The format is "pkg://solaris/system/kernel@0.5.11,5.11-0.161:20110315T070332Z"
|
---|
308 | # or "pkg://solaris/system/kernel@5.12,5.11-5.12.0.0.0.4.1:20120908T030246Z"
|
---|
309 | # or "pkg://solaris/system/kernel@0.5.11,5.11-0.175.0.0.0.1.0:20111012T032837Z"
|
---|
310 | # or "pkg://solaris/system/kernel@5.12-5.12.0.0.0.9.1.3.0:20121012T032837Z" [1]
|
---|
311 | # [1]: The sed below doesn't handle this. It's instead parsed below in the PSARC/2012/240 case.
|
---|
312 | STR_KERN_MAJOR=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\,.*//'`
|
---|
313 | if test ! -z "$STR_KERN_MAJOR"; then
|
---|
314 | # The format is "0.5.11" or "5.12"
|
---|
315 | # Let us just hardcode these for now, instead of trying to do things more generically. It's not
|
---|
316 | # worth trying to bring more order to chaos as it's clear that the version numbering is subject to breakage
|
---|
317 | # as it has been seen in the past.
|
---|
318 | if test "x$STR_KERN_MAJOR" = "x5.12"; then
|
---|
319 | HOST_OS_MAJORVERSION="12"
|
---|
320 | elif test "x$STR_KERN_MAJOR" = "x0.5.11" || test "x$STR_KERN_MAJOR" = "x5.11"; then
|
---|
321 | HOST_OS_MAJORVERSION="11"
|
---|
322 | else
|
---|
323 | # This could be the PSARC/2012/240 naming scheme for S12.
|
---|
324 | # The format is "pkg://solaris/system/kernel@5.12-5.12.0.0.0.9.1.3.0:20121012T032837Z"
|
---|
325 | # The "5.12" following the "@" is the nominal version which we ignore for now as it is
|
---|
326 | # not set by most pkg(5) tools...
|
---|
327 | # STR_KERN_MAJOR is now of the format "5.12-5.12.0.0.0.9.1.3.0:20121012T032837Z" with '9' representing
|
---|
328 | # the build number.
|
---|
329 | BRANCH_VERSION=$STR_KERN_MAJOR
|
---|
330 | HOST_OS_MAJORVERSION=`echo "$BRANCH_VERSION" | cut -f2 -d'-' | cut -f1,2 -d'.'`
|
---|
331 | if test "x$HOST_OS_MAJORVERSION" = "x5.12"; then
|
---|
332 | HOST_OS_MAJORVERSION="12"
|
---|
333 | HOST_OS_MINORVERSION=`echo "$BRANCH_VERSION" | cut -f2 -d'-' | cut -f6 -d'.'`
|
---|
334 | return 0
|
---|
335 | else
|
---|
336 | errorprint "Failed to parse the Solaris kernel major version."
|
---|
337 | exit 1
|
---|
338 | fi
|
---|
339 | fi
|
---|
340 |
|
---|
341 | # This applies only to S11 and S12 where the transitional "@5.12," component version is
|
---|
342 | # still part of the pkg(5) package FMRI. The regular S12 will follow the PSARC/2012/240 naming scheme above.
|
---|
343 | STR_KERN_MINOR=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\:.*//;s/.*,//'`
|
---|
344 | if test ! -z "$STR_KERN_MINOR"; then
|
---|
345 | # The HOST_OS_MINORVERSION is represented as follows:
|
---|
346 | # For S12 it represents the build numbers. e.g. for 4 : "5.11-5.12.0.0.0.4.1"
|
---|
347 | # For S11 as the "nevada" version numbers. e.g. for 175: "5.11-0.161" or "5.11-0.175.0.0.0.1.0"
|
---|
348 | if test "$HOST_OS_MAJORVERSION" -eq 12; then
|
---|
349 | HOST_OS_MINORVERSION=`echo "$STR_KERN_MINOR" | cut -f2 -d'-' | cut -f6 -d'.'`
|
---|
350 | elif test "$HOST_OS_MAJORVERSION" -eq 11; then
|
---|
351 | HOST_OS_MINORVERSION=`echo "$STR_KERN_MINOR" | cut -f2 -d'-' | cut -f2 -d'.'`
|
---|
352 | else
|
---|
353 | errorprint "Solaris kernel major version $HOST_OS_MAJORVERSION not supported."
|
---|
354 | exit 1
|
---|
355 | fi
|
---|
356 | else
|
---|
357 | errorprint "Failed to parse the Solaris kernel minor version."
|
---|
358 | exit 1
|
---|
359 | fi
|
---|
360 | else
|
---|
361 | errorprint "Failed to parse the Solaris kernel package version."
|
---|
362 | exit 1
|
---|
363 | fi
|
---|
364 | else
|
---|
365 | errorprint "Failed to detect the Solaris kernel package FMRI."
|
---|
366 | exit 1
|
---|
367 | fi
|
---|
368 | else
|
---|
369 | HOST_OS_MAJORVERSION=`uname -r`
|
---|
370 | if test -z "$HOST_OS_MAJORVERSION" || test "x$HOST_OS_MAJORVERSION" != "x5.10"; then
|
---|
371 | # S11 without 'pkg'?? Something's wrong... bail.
|
---|
372 | errorprint "Solaris $HOST_OS_MAJORVERSION detected without executable $BIN_PKG !? I are confused."
|
---|
373 | exit 1
|
---|
374 | fi
|
---|
375 | HOST_OS_MAJORVERSION="10"
|
---|
376 | if test "$REMOTEINST" -eq 0; then
|
---|
377 | # Use uname to verify it's S10.
|
---|
378 | # Major version is S10, Minor version is no longer relevant (or used), use uname -v so it gets something
|
---|
379 | # like "Generic_blah" for purely cosmetic purposes
|
---|
380 | HOST_OS_MINORVERSION=`uname -v`
|
---|
381 | else
|
---|
382 | # Remote installs from S10 local.
|
---|
383 | BIN_PKGCHK=`which pkgchk 2> /dev/null`
|
---|
384 | if test ! -x "$BIN_PKGCHK"; then
|
---|
385 | errorprint "Failed to find an executable pkgchk binary $BIN_PKGCHK."
|
---|
386 | errorprint "Cannot determine Solaris version on remote target $PKG_INSTALL_ROOT"
|
---|
387 | exit 1
|
---|
388 | fi
|
---|
389 |
|
---|
390 | REMOTE_S10=`$BIN_PKGCHK -l -p /kernel/amd64/genunix $BASEDIR_PKGOPT 2> /dev/null | grep SUNWckr | tr -d ' \t'`
|
---|
391 | if test ! -z "$REMOTE_S10" && test "x$REMOTE_S10" = "xSUNWckr"; then
|
---|
392 | HOST_OS_MAJORVERSION="10"
|
---|
393 | HOST_OS_MINORVERSION=""
|
---|
394 | else
|
---|
395 | errorprint "Remote target $PKG_INSTALL_ROOT is not Solaris 10."
|
---|
396 | errorprint "Will not attempt to install to an unidentified remote target."
|
---|
397 | exit 1
|
---|
398 | fi
|
---|
399 | fi
|
---|
400 | fi
|
---|
401 | }
|
---|
402 |
|
---|
403 | # check_zone()
|
---|
404 | # !! failure is always fatal
|
---|
405 | check_zone()
|
---|
406 | {
|
---|
407 | currentzone=`zonename`
|
---|
408 | if test "x$currentzone" != "xglobal"; then
|
---|
409 | errorprint "This script must be run from the global zone."
|
---|
410 | exit 1
|
---|
411 | fi
|
---|
412 | }
|
---|
413 |
|
---|
414 | # check_isa()
|
---|
415 | # !! failure is always fatal
|
---|
416 | check_isa()
|
---|
417 | {
|
---|
418 | currentisa=`uname -i`
|
---|
419 | if test "x$currentisa" = "xi86xpv"; then
|
---|
420 | errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
|
---|
421 | exit 1
|
---|
422 | fi
|
---|
423 | }
|
---|
424 |
|
---|
425 | # check_module_arch()
|
---|
426 | # !! failure is always fatal
|
---|
427 | check_module_arch()
|
---|
428 | {
|
---|
429 | cputype=`isainfo -k`
|
---|
430 | if test "x$cputype" != "xamd64" && test "x$cputype" != "xi386"; then
|
---|
431 | errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
|
---|
432 | exit 1
|
---|
433 | fi
|
---|
434 | }
|
---|
435 |
|
---|
436 | # update_boot_archive()
|
---|
437 | # cannot fail
|
---|
438 | update_boot_archive()
|
---|
439 | {
|
---|
440 | infoprint "Updating the boot archive..."
|
---|
441 | if test "$REMOTEINST" -eq 0; then
|
---|
442 | $BIN_BOOTADM update-archive > /dev/null
|
---|
443 | else
|
---|
444 | $BIN_BOOTADM update-archive -R "$PKG_INSTALL_ROOT" > /dev/null
|
---|
445 | fi
|
---|
446 | UPDATEBOOTARCHIVE=0
|
---|
447 | }
|
---|
448 |
|
---|
449 |
|
---|
450 | # module_added(modname)
|
---|
451 | # returns 1 if added, 0 otherwise
|
---|
452 | module_added()
|
---|
453 | {
|
---|
454 | if test -z "$1"; then
|
---|
455 | errorprint "missing argument to module_added()"
|
---|
456 | exit 1
|
---|
457 | fi
|
---|
458 |
|
---|
459 | # Add a space at end of module name to make sure we have a perfect match to avoid
|
---|
460 | # any substring matches: e.g "vboxusb" & "vboxusbmon"
|
---|
461 | loadentry=`cat "$PKG_INSTALL_ROOT/etc/name_to_major" | grep "$1 "`
|
---|
462 | if test -z "$loadentry"; then
|
---|
463 | return 1
|
---|
464 | fi
|
---|
465 | return 0
|
---|
466 | }
|
---|
467 |
|
---|
468 | # module_loaded(modname)
|
---|
469 | # returns 1 if loaded, 0 otherwise
|
---|
470 | module_loaded()
|
---|
471 | {
|
---|
472 | if test -z "$1"; then
|
---|
473 | errorprint "missing argument to module_loaded()"
|
---|
474 | exit 1
|
---|
475 | fi
|
---|
476 |
|
---|
477 | modname=$1
|
---|
478 | # modinfo should now work properly since we prevent module autounloading.
|
---|
479 | loadentry=`$BIN_MODINFO | grep "$modname "`
|
---|
480 | if test -z "$loadentry"; then
|
---|
481 | return 1
|
---|
482 | fi
|
---|
483 | return 0
|
---|
484 | }
|
---|
485 |
|
---|
486 | # add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
|
---|
487 | # failure: depends on "fatal"
|
---|
488 | add_driver()
|
---|
489 | {
|
---|
490 | if test -z "$1" || test -z "$2"; then
|
---|
491 | errorprint "missing argument to add_driver()"
|
---|
492 | exit 1
|
---|
493 | fi
|
---|
494 |
|
---|
495 | modname="$1"
|
---|
496 | moddesc="$2"
|
---|
497 | fatal="$3"
|
---|
498 | nullop="$4"
|
---|
499 | modperm="$5"
|
---|
500 |
|
---|
501 | if test -n "$modperm"; then
|
---|
502 | if test "x$nullop" = "x$NULLOP"; then
|
---|
503 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
|
---|
504 | else
|
---|
505 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
|
---|
506 | fi
|
---|
507 | else
|
---|
508 | if test "x$nullop" = "x$NULLOP"; then
|
---|
509 | $BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
510 | else
|
---|
511 | $BIN_ADDDRV $BASEDIR_OPT $modname
|
---|
512 | fi
|
---|
513 | fi
|
---|
514 |
|
---|
515 | if test "$?" -ne 0; then
|
---|
516 | subprint "Adding: $moddesc module ...FAILED!"
|
---|
517 | if test "x$fatal" = "x$FATALOP"; then
|
---|
518 | exit 1
|
---|
519 | fi
|
---|
520 | return 1
|
---|
521 | fi
|
---|
522 | subprint "Added: $moddesc driver"
|
---|
523 | return 0
|
---|
524 | }
|
---|
525 |
|
---|
526 | # rem_driver(modname, moddesc, [fatal])
|
---|
527 | # failure: depends on [fatal]
|
---|
528 | rem_driver()
|
---|
529 | {
|
---|
530 | if test -z "$1" || test -z "$2"; then
|
---|
531 | errorprint "missing argument to rem_driver()"
|
---|
532 | exit 1
|
---|
533 | fi
|
---|
534 |
|
---|
535 | modname=$1
|
---|
536 | moddesc=$2
|
---|
537 | fatal=$3
|
---|
538 |
|
---|
539 | module_added $modname
|
---|
540 | if test "$?" -eq 0; then
|
---|
541 | UPDATEBOOTARCHIVE=1
|
---|
542 | if test "x$ISIPS" != "x$IPSOP"; then
|
---|
543 | $BIN_REMDRV $BASEDIR_OPT $modname
|
---|
544 | else
|
---|
545 | $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
546 | fi
|
---|
547 | # for remote installs, don't bother with return values of rem_drv
|
---|
548 | if test "$?" -eq 0 || test "$REMOTEINST" -eq 1; then
|
---|
549 | subprint "Removed: $moddesc driver"
|
---|
550 | return 0
|
---|
551 | else
|
---|
552 | subprint "Removing: $moddesc ...FAILED!"
|
---|
553 | if test "x$fatal" = "x$FATALOP"; then
|
---|
554 | exit 1
|
---|
555 | fi
|
---|
556 | return 1
|
---|
557 | fi
|
---|
558 | fi
|
---|
559 | }
|
---|
560 |
|
---|
561 | # unload_module(modname, moddesc, retry, [fatal])
|
---|
562 | # failure: fatal
|
---|
563 | unload_module()
|
---|
564 | {
|
---|
565 | if test -z "$1" || test -z "$2"; then
|
---|
566 | errorprint "missing argument to unload_module()"
|
---|
567 | exit 1
|
---|
568 | fi
|
---|
569 |
|
---|
570 | # No-OP for non-root installs
|
---|
571 | if test "$REMOTEINST" -eq 1; then
|
---|
572 | return 0
|
---|
573 | fi
|
---|
574 |
|
---|
575 | modname=$1
|
---|
576 | moddesc=$2
|
---|
577 | retry=$3
|
---|
578 | fatal=$4
|
---|
579 | modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
|
---|
580 | if test -n "$modid"; then
|
---|
581 | $BIN_MODUNLOAD -i $modid
|
---|
582 | if test "$?" -eq 0; then
|
---|
583 | subprint "Unloaded: $moddesc module"
|
---|
584 | else
|
---|
585 | #
|
---|
586 | # Hack for vboxdrv. Delayed removing when VMM thread-context hooks are used.
|
---|
587 | # Our automated tests are probably too quick... Fix properly later.
|
---|
588 | #
|
---|
589 | result="$?"
|
---|
590 | if test "$retry" -eq 1; then
|
---|
591 | cmax=15
|
---|
592 | cslept=0
|
---|
593 | while test "$result" -ne 0;
|
---|
594 | do
|
---|
595 | subprint "Unloading: $moddesc module ...FAILED! Busy? Retrying in 3 seconds..."
|
---|
596 | sleep 3
|
---|
597 | cslept=`expr $cslept + 3`
|
---|
598 | if test "$cslept" -ge "$cmax"; then
|
---|
599 | break
|
---|
600 | fi
|
---|
601 | $BIN_MODUNLOAD -i $modid
|
---|
602 | result="$?"
|
---|
603 | done
|
---|
604 | fi
|
---|
605 |
|
---|
606 | if test "$result" -ne 0; then
|
---|
607 | subprint "Unloading: $moddesc module ...FAILED!"
|
---|
608 | if test "x$fatal" = "x$FATALOP"; then
|
---|
609 | exit 1
|
---|
610 | fi
|
---|
611 | else
|
---|
612 | subprint "Unloaded: $moddesc module"
|
---|
613 | fi
|
---|
614 | return 1
|
---|
615 | fi
|
---|
616 | fi
|
---|
617 | return 0
|
---|
618 | }
|
---|
619 |
|
---|
620 | # load_module(modname, moddesc, [fatal])
|
---|
621 | # pass "drv/modname" or "misc/vbi" etc.
|
---|
622 | # failure: fatal
|
---|
623 | load_module()
|
---|
624 | {
|
---|
625 | if test -z "$1" || test -z "$2"; then
|
---|
626 | errorprint "missing argument to load_module()"
|
---|
627 | exit 1
|
---|
628 | fi
|
---|
629 |
|
---|
630 | # No-OP for non-root installs
|
---|
631 | if test "$REMOTEINST" -eq 1; then
|
---|
632 | return 0
|
---|
633 | fi
|
---|
634 |
|
---|
635 | modname=$1
|
---|
636 | moddesc=$2
|
---|
637 | fatal=$3
|
---|
638 | $BIN_MODLOAD -p $modname
|
---|
639 | if test "$?" -eq 0; then
|
---|
640 | return 0
|
---|
641 | else
|
---|
642 | subprint "Loading: $moddesc module ...FAILED!"
|
---|
643 | if test "x$fatal" = "x$FATALOP"; then
|
---|
644 | exit 1
|
---|
645 | fi
|
---|
646 | return 1
|
---|
647 | fi
|
---|
648 | }
|
---|
649 |
|
---|
650 | load_vboxflt()
|
---|
651 | {
|
---|
652 | if test -f "$DIR_CONF/vboxflt.conf"; then
|
---|
653 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
654 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
655 | else
|
---|
656 | # For custom pkgs that optionally ship this module, let's not fail but just warn
|
---|
657 | warnprint "$DESC_VBOXFLT installation requested but not shipped in this package."
|
---|
658 | fi
|
---|
659 | }
|
---|
660 |
|
---|
661 | load_vboxbow()
|
---|
662 | {
|
---|
663 | if test -f "$DIR_CONF/vboxbow.conf"; then
|
---|
664 | add_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
|
---|
665 | load_module "drv/$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
|
---|
666 | else
|
---|
667 | # For custom pkgs that optionally ship this module, let's not fail but just warn
|
---|
668 | warnprint "$DESC_VBOXBOW installation requested but not shipped in this package."
|
---|
669 | fi
|
---|
670 | }
|
---|
671 |
|
---|
672 | # install_drivers()
|
---|
673 | # !! failure is always fatal
|
---|
674 | install_drivers()
|
---|
675 | {
|
---|
676 | if test -f "$DIR_CONF/vboxdrv.conf"; then
|
---|
677 | if test -n "_HARDENED_"; then
|
---|
678 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys','vboxdrvu 0666 root sys'"
|
---|
679 | else
|
---|
680 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys','vboxdrvu 0666 root sys'"
|
---|
681 | fi
|
---|
682 | load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
|
---|
683 | else
|
---|
684 | errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
|
---|
685 | return 1
|
---|
686 | fi
|
---|
687 |
|
---|
688 | # Figure out group to use for /etc/devlink.tab (before Solaris 11 SRU6
|
---|
689 | # it was always using group sys)
|
---|
690 | group=sys
|
---|
691 | if [ -f "$PKG_INSTALL_ROOT/etc/dev/reserved_devnames" ]; then
|
---|
692 | # Solaris 11 SRU6 and later use group root (check a file which isn't
|
---|
693 | # tainted by VirtualBox install scripts and allow no other group)
|
---|
694 | refgroup=`LC_ALL=C /usr/bin/ls -lL "$PKG_INSTALL_ROOT/etc/dev/reserved_devnames" | awk '{ print $4 }' 2>/dev/null`
|
---|
695 | if [ $? -eq 0 -a "x$refgroup" = "xroot" ]; then
|
---|
696 | group=root
|
---|
697 | fi
|
---|
698 | unset refgroup
|
---|
699 | fi
|
---|
700 |
|
---|
701 | ## Add vboxdrv to devlink.tab (KEEP TABS!)
|
---|
702 | if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
|
---|
703 | sed -e '/name=vboxdrv/d' -e '/name=vboxdrvu/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
704 | echo "type=ddi_pseudo;name=vboxdrv;minor=vboxdrv \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
705 | echo "type=ddi_pseudo;name=vboxdrv;minor=vboxdrvu \M0" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
706 | chmod 0644 "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
707 | chown root:$group "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
708 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
709 | else
|
---|
710 | errorprint "Missing $PKG_INSTALL_ROOT/etc/devlink.tab, aborting install"
|
---|
711 | return 1
|
---|
712 | fi
|
---|
713 |
|
---|
714 | # Create the device link for non-remote installs (not really relevant any more)
|
---|
715 | if test "$REMOTEINST" -eq 0; then
|
---|
716 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
717 | if test "$?" -ne 0 || test ! -h "/dev/vboxdrv" || test ! -h "/dev/vboxdrvu" ; then
|
---|
718 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
719 | exit 1
|
---|
720 | fi
|
---|
721 | fi
|
---|
722 |
|
---|
723 | # Load VBoxNetAdp
|
---|
724 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
725 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
726 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
727 | fi
|
---|
728 |
|
---|
729 | # If both vboxinst_vboxbow and vboxinst_vboxflt exist, bail.
|
---|
730 | if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt" && test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
|
---|
731 | errorprint "Force-install files '$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt' and '$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow' both exist."
|
---|
732 | errorprint "Cannot load $DESC_VBOXFLT and $DESC_VBOXBOW drivers at the same time."
|
---|
733 | return 1
|
---|
734 | fi
|
---|
735 |
|
---|
736 | # If the force-install files exists, install blindly
|
---|
737 | if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt"; then
|
---|
738 | subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxflt."
|
---|
739 | load_vboxflt
|
---|
740 | elif test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
|
---|
741 | subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxbow."
|
---|
742 | load_vboxbow
|
---|
743 | else
|
---|
744 | # If host is S10 or S11 (< snv_159) or vboxbow isn't shipped, then load vboxflt
|
---|
745 | if test "$HOST_OS_MAJORVERSION" -eq 10 \
|
---|
746 | || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -lt 159) \
|
---|
747 | || test ! -f "$DIR_CONF/vboxbow.conf"; then
|
---|
748 | load_vboxflt
|
---|
749 | else
|
---|
750 | # For S11 snv_159+ load vboxbow
|
---|
751 | load_vboxbow
|
---|
752 | fi
|
---|
753 | fi
|
---|
754 |
|
---|
755 | # Load VBoxUSBMon, VBoxUSB
|
---|
756 | try_vboxusb="no"
|
---|
757 | if test -f "$DIR_CONF/vboxusbmon.conf"; then
|
---|
758 | if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxusb"; then
|
---|
759 | subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxusb."
|
---|
760 | try_vboxusb="yes"
|
---|
761 | else
|
---|
762 | # For VirtualBox 3.1 the new USB code requires Nevada > 123 i.e. S12+ or S11 b124+
|
---|
763 | if test "$HOST_OS_MAJORVERSION" -gt 11 \
|
---|
764 | || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 123); then
|
---|
765 | try_vboxusb="yes"
|
---|
766 | else
|
---|
767 | warnprint "Solaris 11 build 124 or higher required for USB support. Skipped installing USB support."
|
---|
768 | fi
|
---|
769 | fi
|
---|
770 | fi
|
---|
771 | if test "x$try_vboxusb" = "xyes"; then
|
---|
772 | # Add a group "vboxuser" (8-character limit) for USB access.
|
---|
773 | # All users which need host USB-passthrough support will have to be added to this group.
|
---|
774 | groupadd vboxuser >/dev/null 2>&1
|
---|
775 |
|
---|
776 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
777 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
778 |
|
---|
779 | chown root:vboxuser "/devices/pseudo/vboxusbmon@0:vboxusbmon"
|
---|
780 |
|
---|
781 | # Add vboxusbmon to devlink.tab
|
---|
782 | sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
783 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
784 | chmod 0644 "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
785 | chown root:$group "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
786 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
787 |
|
---|
788 | # Create the device link for non-remote installs
|
---|
789 | if test "$REMOTEINST" -eq 0; then
|
---|
790 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
791 | if test "$?" -ne 0; then
|
---|
792 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
793 | exit 1
|
---|
794 | fi
|
---|
795 | fi
|
---|
796 |
|
---|
797 | # Add vboxusb if present
|
---|
798 | # This driver is special, we need it in the boot-archive but since there is no
|
---|
799 | # USB device to attach to now (it's done at runtime) it will fail to attach so
|
---|
800 | # redirect attaching failure output to /dev/null
|
---|
801 | if test -f "$DIR_CONF/vboxusb.conf"; then
|
---|
802 | add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
|
---|
803 | load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
|
---|
804 | fi
|
---|
805 | fi
|
---|
806 |
|
---|
807 | return $?
|
---|
808 | }
|
---|
809 |
|
---|
810 | # remove_drivers([fatal])
|
---|
811 | # failure: depends on [fatal]
|
---|
812 | remove_drivers()
|
---|
813 | {
|
---|
814 | fatal=$1
|
---|
815 |
|
---|
816 | # Figure out group to use for /etc/devlink.tab (before Solaris 11 SRU6
|
---|
817 | # it was always using group sys)
|
---|
818 | group=sys
|
---|
819 | if [ -f "$PKG_INSTALL_ROOT/etc/dev/reserved_devnames" ]; then
|
---|
820 | # Solaris 11 SRU6 and later use group root (check a file which isn't
|
---|
821 | # tainted by VirtualBox install scripts and allow no other group)
|
---|
822 | refgroup=`LC_ALL=C /usr/bin/ls -lL "$PKG_INSTALL_ROOT/etc/dev/reserved_devnames" | awk '{ print $4 }' 2>/dev/null`
|
---|
823 | if [ $? -eq 0 -a "x$refgroup" = "xroot" ]; then
|
---|
824 | group=root
|
---|
825 | fi
|
---|
826 | unset refgroup
|
---|
827 | fi
|
---|
828 |
|
---|
829 | # Remove vboxdrv[u] from devlink.tab
|
---|
830 | if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
|
---|
831 | devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxdrv`
|
---|
832 | if test -n "$devlinkfound"; then
|
---|
833 | sed -e '/name=vboxdrv/d' -e '/name=vboxdrvu/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
834 | chmod 0644 "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
835 | chown root:$group "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
836 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
837 | fi
|
---|
838 |
|
---|
839 | # Remove vboxusbmon from devlink.tab
|
---|
840 | devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxusbmon`
|
---|
841 | if test -n "$devlinkfound"; then
|
---|
842 | sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
843 | chmod 0644 "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
844 | chown root:$group "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
845 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
846 | fi
|
---|
847 | fi
|
---|
848 |
|
---|
849 | unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" 0 "$fatal"
|
---|
850 | rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
851 |
|
---|
852 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" 0 "$fatal"
|
---|
853 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
854 |
|
---|
855 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" 0 "$fatal"
|
---|
856 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
857 |
|
---|
858 | unload_module "$MOD_VBOXBOW" "$DESC_VBOXBOW" 0 "$fatal"
|
---|
859 | rem_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
|
---|
860 |
|
---|
861 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" 0 "$fatal"
|
---|
862 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
863 |
|
---|
864 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" 1 "$fatal"
|
---|
865 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
866 |
|
---|
867 | # remove devlinks
|
---|
868 | if test -h "$PKG_INSTALL_ROOT/dev/vboxdrv" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrv"; then
|
---|
869 | rm -f "$PKG_INSTALL_ROOT/dev/vboxdrv"
|
---|
870 | fi
|
---|
871 | if test -h "$PKG_INSTALL_ROOT/dev/vboxdrvu" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrvu"; then
|
---|
872 | rm -f "$PKG_INSTALL_ROOT/dev/vboxdrvu"
|
---|
873 | fi
|
---|
874 | if test -h "$PKG_INSTALL_ROOT/dev/vboxusbmon" || test -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"; then
|
---|
875 | rm -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"
|
---|
876 | fi
|
---|
877 |
|
---|
878 | # unpatch nwam/dhcpagent fix
|
---|
879 | nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
|
---|
880 | nwambackupfile=$nwamfile.vbox
|
---|
881 | if test -f "$nwamfile"; then
|
---|
882 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
883 | mv -f $nwambackupfile $nwamfile
|
---|
884 | fi
|
---|
885 |
|
---|
886 | # remove netmask configuration
|
---|
887 | if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
|
---|
888 | nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
889 | else
|
---|
890 | nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
891 | fi
|
---|
892 | nmaskbackupfile=$nmaskfile.vbox
|
---|
893 | if test -f "$nmaskfile"; then
|
---|
894 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
895 | mv -f $nmaskbackupfile $nmaskfile
|
---|
896 | fi
|
---|
897 |
|
---|
898 | if test $UPDATEBOOTARCHIVE -eq 1; then
|
---|
899 | update_boot_archive
|
---|
900 | fi
|
---|
901 |
|
---|
902 | return 0
|
---|
903 | }
|
---|
904 |
|
---|
905 | # install_python_bindings(pythonbin pythondesc)
|
---|
906 | # failure: non fatal
|
---|
907 | install_python_bindings()
|
---|
908 | {
|
---|
909 | pythonbin="$1"
|
---|
910 | pythondesc="$2"
|
---|
911 |
|
---|
912 | # The python binary might not be there, so just exit silently
|
---|
913 | if test -z "$pythonbin"; then
|
---|
914 | return 0
|
---|
915 | fi
|
---|
916 |
|
---|
917 | if test -z "$pythondesc"; then
|
---|
918 | errorprint "missing argument to install_python_bindings"
|
---|
919 | return 1
|
---|
920 | fi
|
---|
921 |
|
---|
922 | infoprint "Python found: $pythonbin, installing bindings..."
|
---|
923 |
|
---|
924 | # check if python has working distutils
|
---|
925 | "$pythonbin" -c "from distutils.core import setup" > /dev/null 2>&1
|
---|
926 | if test "$?" -ne 0; then
|
---|
927 | subprint "Skipped: $pythondesc install is unusable, missing package 'distutils'"
|
---|
928 | return 0
|
---|
929 | fi
|
---|
930 |
|
---|
931 | # Pass install path via environment
|
---|
932 | export VBOX_INSTALL_PATH
|
---|
933 | mkdir -p "$CONFIG_DIR"
|
---|
934 | rm -f "$CONFIG_DIR/python-$CONFIG_FILES"
|
---|
935 | $SHELL -c "cd \"$VBOX_INSTALL_PATH\"/sdk/installer && \"$pythonbin\" ./vboxapisetup.py install \
|
---|
936 | --record \"$CONFIG_DIR/python-$CONFIG_FILES\"" > /dev/null 2>&1
|
---|
937 | if test "$?" -eq 0; then
|
---|
938 | cat "$CONFIG_DIR/python-$CONFIG_FILES" >> "$CONFIG_DIR/$CONFIG_FILES"
|
---|
939 | else
|
---|
940 | errorprint "Failed to install bindings for $pythondesc"
|
---|
941 | fi
|
---|
942 | rm "$CONFIG_DIR/python-$CONFIG_FILES"
|
---|
943 |
|
---|
944 | # Remove files created by Python API setup.
|
---|
945 | rm -rf $VBOX_INSTALL_PATH/sdk/installer/build
|
---|
946 | return 0
|
---|
947 | }
|
---|
948 |
|
---|
949 | # is_process_running(processname)
|
---|
950 | # returns 1 if the process is running, 0 otherwise
|
---|
951 | is_process_running()
|
---|
952 | {
|
---|
953 | if test -z "$1"; then
|
---|
954 | errorprint "missing argument to is_process_running()"
|
---|
955 | exit 1
|
---|
956 | fi
|
---|
957 |
|
---|
958 | procname="$1"
|
---|
959 | $BIN_PGREP "$procname" > /dev/null 2>&1
|
---|
960 | if test "$?" -eq 0; then
|
---|
961 | return 1
|
---|
962 | fi
|
---|
963 | return 0
|
---|
964 | }
|
---|
965 |
|
---|
966 |
|
---|
967 | # stop_process(processname)
|
---|
968 | # failure: depends on [fatal]
|
---|
969 | stop_process()
|
---|
970 | {
|
---|
971 | if test -z "$1"; then
|
---|
972 | errorprint "missing argument to stop_process()"
|
---|
973 | exit 1
|
---|
974 | fi
|
---|
975 |
|
---|
976 | procname="$1"
|
---|
977 | is_process_running "$procname"
|
---|
978 | if test "$?" -eq 1; then
|
---|
979 | $BIN_PKILL "$procname"
|
---|
980 | sleep 2
|
---|
981 | is_process_running "$procname"
|
---|
982 | if test "$?" -eq 1; then
|
---|
983 | subprint "Terminating: $procname ...FAILED!"
|
---|
984 | if test "x$fatal" = "x$FATALOP"; then
|
---|
985 | exit 1
|
---|
986 | fi
|
---|
987 | else
|
---|
988 | subprint "Terminated: $procname"
|
---|
989 | fi
|
---|
990 | fi
|
---|
991 | }
|
---|
992 |
|
---|
993 | # start_service(servicename, shortFMRI pretty printing, full FMRI, log-file path)
|
---|
994 | # failure: non-fatal
|
---|
995 | start_service()
|
---|
996 | {
|
---|
997 | if test -z "$1" || test -z "$2" || test -z "$3" || test -z "$4"; then
|
---|
998 | errorprint "missing argument to enable_service()"
|
---|
999 | exit 1
|
---|
1000 | fi
|
---|
1001 |
|
---|
1002 | # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
|
---|
1003 | # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
|
---|
1004 | # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
|
---|
1005 | cmax=32
|
---|
1006 | cslept=0
|
---|
1007 | success=0
|
---|
1008 |
|
---|
1009 | $BIN_SVCS "$3" >/dev/null 2>&1
|
---|
1010 | while test "$?" -ne 0;
|
---|
1011 | do
|
---|
1012 | sleep 1
|
---|
1013 | cslept=`expr $cslept + 1`
|
---|
1014 | if test "$cslept" -eq "$cmax"; then
|
---|
1015 | success=1
|
---|
1016 | break
|
---|
1017 | fi
|
---|
1018 | $BIN_SVCS "$3" >/dev/null 2>&1
|
---|
1019 | done
|
---|
1020 | if test "$success" -eq 0; then
|
---|
1021 | $BIN_SVCADM enable -s "$3"
|
---|
1022 | if test "$?" -eq 0; then
|
---|
1023 | subprint "Enabled: $1"
|
---|
1024 | return 0
|
---|
1025 | else
|
---|
1026 | warnprint "Enabling $1 ...FAILED."
|
---|
1027 | warnprint "Refer $4 for details."
|
---|
1028 | fi
|
---|
1029 | else
|
---|
1030 | warnprint "Importing $1 ...FAILED."
|
---|
1031 | warnprint "Refer /var/svc/log/system-manifest-import:default.log for details."
|
---|
1032 | fi
|
---|
1033 | return 1
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | # stop_service(servicename, shortFMRI-suitable for grep, full FMRI)
|
---|
1038 | # failure: non fatal
|
---|
1039 | stop_service()
|
---|
1040 | {
|
---|
1041 | if test -z "$1" || test -z "$2" || test -z "$3"; then
|
---|
1042 | errorprint "missing argument to stop_service()"
|
---|
1043 | exit 1
|
---|
1044 | fi
|
---|
1045 | servicefound=`$BIN_SVCS -H "$2" 2>/dev/null | grep '^online'`
|
---|
1046 | if test ! -z "$servicefound"; then
|
---|
1047 | $BIN_SVCADM disable -s "$3"
|
---|
1048 | # Don't delete the manifest, this is handled by the manifest class action
|
---|
1049 | # $BIN_SVCCFG delete "$3"
|
---|
1050 | if test "$?" -eq 0; then
|
---|
1051 | subprint "Disabled: $1"
|
---|
1052 | else
|
---|
1053 | subprint "Disabling: $1 ...ERROR(S)."
|
---|
1054 | fi
|
---|
1055 | fi
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 |
|
---|
1059 | # plumb vboxnet0 instance
|
---|
1060 | # failure: non fatal
|
---|
1061 | plumb_net()
|
---|
1062 | {
|
---|
1063 | # S11 175a renames vboxnet0 as 'netX', undo this and rename it back (Solaris 12, Solaris 11.4 or newer)
|
---|
1064 | if test "$HOST_OS_MAJORVERSION" -ge 12 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -ge 175); then
|
---|
1065 | vanityname=`dladm show-phys -po link,device | grep vboxnet0 | cut -f1 -d':'`
|
---|
1066 | if test "$?" -eq 0 && test ! -z "$vanityname" && test "x$vanityname" != "xvboxnet0"; then
|
---|
1067 | dladm rename-link "$vanityname" vboxnet0
|
---|
1068 | if test "$?" -ne 0; then
|
---|
1069 | errorprint "Failed to rename vanity interface ($vanityname) to vboxnet0"
|
---|
1070 | fi
|
---|
1071 | fi
|
---|
1072 | fi
|
---|
1073 |
|
---|
1074 | # use ipadm for Solaris 12, Solaris 11.5 or newer
|
---|
1075 | if test "$HOST_OS_MAJORVERSION" -ge 12 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -ge 176); then
|
---|
1076 | $BIN_IPADM create-ip vboxnet0
|
---|
1077 | if test "$?" -eq 0; then
|
---|
1078 | $BIN_IPADM create-addr -T static -a local="192.168.56.1/24" "vboxnet0/v4addr"
|
---|
1079 | if test "$?" -eq 0; then
|
---|
1080 | subprint "Configured: NetAdapter 'vboxnet0'"
|
---|
1081 | else
|
---|
1082 | warnprint "Failed to create local address for vboxnet0!"
|
---|
1083 | fi
|
---|
1084 | else
|
---|
1085 | warnprint "Failed to create IP instance for vboxnet0!"
|
---|
1086 | fi
|
---|
1087 | else
|
---|
1088 | $BIN_IFCONFIG vboxnet0 plumb
|
---|
1089 | $BIN_IFCONFIG vboxnet0 up
|
---|
1090 | if test "$?" -eq 0; then
|
---|
1091 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
1092 |
|
---|
1093 | # /etc/netmasks is a symlink, older installers replaced this with
|
---|
1094 | # a copy of the actual file, repair that behaviour here.
|
---|
1095 | recreatelink=0
|
---|
1096 | if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
|
---|
1097 | nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
1098 | else
|
---|
1099 | nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
1100 | recreatelink=1
|
---|
1101 | fi
|
---|
1102 |
|
---|
1103 | # add the netmask to stay persistent across host reboots
|
---|
1104 | nmaskbackupfile=$nmaskfile.vbox
|
---|
1105 | if test -f $nmaskfile; then
|
---|
1106 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
1107 |
|
---|
1108 | if test "$recreatelink" -eq 1; then
|
---|
1109 | # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
|
---|
1110 | anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
|
---|
1111 | if test ! -z "$anydiff"; then
|
---|
1112 | # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
|
---|
1113 | recreatelink=2
|
---|
1114 | fi
|
---|
1115 | fi
|
---|
1116 |
|
---|
1117 | echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
|
---|
1118 | inst=0
|
---|
1119 | networkn=56
|
---|
1120 | while test "$inst" -ne 1; do
|
---|
1121 | echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
|
---|
1122 | inst=`expr $inst + 1`
|
---|
1123 | networkn=`expr $networkn + 1`
|
---|
1124 | done
|
---|
1125 | echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
|
---|
1126 | mv -f $nmaskbackupfile $nmaskfile
|
---|
1127 |
|
---|
1128 | # Recreate /etc/netmasks as a link if necessary
|
---|
1129 | if test "$recreatelink" -eq 1; then
|
---|
1130 | cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
1131 | ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
1132 | elif test "$recreatelink" -eq 2; then
|
---|
1133 | warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
|
---|
1134 | warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
|
---|
1135 | warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
|
---|
1136 | warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
|
---|
1137 | warnprint "symlink to /etc/inet/netmasks. Please resolve this manually"
|
---|
1138 | warnprint "by updating /etc/inet/netmasks and creating /etc/netmasks as a"
|
---|
1139 | warnprint "symlink to /etc/inet/netmasks"
|
---|
1140 | fi
|
---|
1141 | fi
|
---|
1142 | else
|
---|
1143 | # Should this be fatal?
|
---|
1144 | warnprint "Failed to bring up vboxnet0!"
|
---|
1145 | fi
|
---|
1146 | fi
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 |
|
---|
1150 | # unplumb all vboxnet instances
|
---|
1151 | # failure: fatal
|
---|
1152 | unplumb_net()
|
---|
1153 | {
|
---|
1154 | inst=0
|
---|
1155 | # use ipadm for Solaris 12, Solaris 11.5 or newer
|
---|
1156 | if test "$HOST_OS_MAJORVERSION" -ge 12 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -ge 176); then
|
---|
1157 | while test "$inst" -ne $MOD_VBOXNET_INST; do
|
---|
1158 | vboxnetup=`$BIN_IPADM show-addr -p -o addrobj vboxnet$inst >/dev/null 2>&1`
|
---|
1159 | if test "$?" -eq 0; then
|
---|
1160 | $BIN_IPADM delete-addr vboxnet$inst/v4addr
|
---|
1161 | $BIN_IPADM delete-ip vboxnet$inst
|
---|
1162 | if test "$?" -ne 0; then
|
---|
1163 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be removed (probably in use)."
|
---|
1164 | if test "x$fatal" = "x$FATALOP"; then
|
---|
1165 | exit 1
|
---|
1166 | fi
|
---|
1167 | fi
|
---|
1168 | fi
|
---|
1169 |
|
---|
1170 | inst=`expr $inst + 1`
|
---|
1171 | done
|
---|
1172 | else
|
---|
1173 | inst=0
|
---|
1174 | while test "$inst" -ne $MOD_VBOXNET_INST; do
|
---|
1175 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
|
---|
1176 | if test "$?" -eq 0; then
|
---|
1177 | $BIN_IFCONFIG vboxnet$inst unplumb
|
---|
1178 | if test "$?" -ne 0; then
|
---|
1179 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
|
---|
1180 | if test "x$fatal" = "x$FATALOP"; then
|
---|
1181 | exit 1
|
---|
1182 | fi
|
---|
1183 | fi
|
---|
1184 | fi
|
---|
1185 |
|
---|
1186 | # unplumb vboxnet0 ipv6
|
---|
1187 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
|
---|
1188 | if test "$?" -eq 0; then
|
---|
1189 | $BIN_IFCONFIG vboxnet$inst inet6 unplumb
|
---|
1190 | if test "$?" -ne 0; then
|
---|
1191 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
|
---|
1192 | if test "x$fatal" = "x$FATALOP"; then
|
---|
1193 | exit 1
|
---|
1194 | fi
|
---|
1195 | fi
|
---|
1196 | fi
|
---|
1197 |
|
---|
1198 | inst=`expr $inst + 1`
|
---|
1199 | done
|
---|
1200 | fi
|
---|
1201 | }
|
---|
1202 |
|
---|
1203 |
|
---|
1204 | # cleanup_install([fatal])
|
---|
1205 | # failure: depends on [fatal]
|
---|
1206 | cleanup_install()
|
---|
1207 | {
|
---|
1208 | fatal=$1
|
---|
1209 |
|
---|
1210 | # No-Op for remote installs
|
---|
1211 | if test "$REMOTEINST" -eq 1; then
|
---|
1212 | return 0
|
---|
1213 | fi
|
---|
1214 |
|
---|
1215 | # stop the services
|
---|
1216 | stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
|
---|
1217 | stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
|
---|
1218 | stop_service "Autostart service" "virtualbox/autostart" "svc:/application/virtualbox/autostart:default"
|
---|
1219 | stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
|
---|
1220 |
|
---|
1221 | # DEBUG x4600b: verify that the ZoneAccess process is really gone
|
---|
1222 | is_process_running "VBoxZoneAccess"
|
---|
1223 | if test "$?" -eq 1; then
|
---|
1224 | warnprint "VBoxZoneAccess is alive despite its service being dead. Killing..."
|
---|
1225 | stop_process "VBoxZoneAccess"
|
---|
1226 | fi
|
---|
1227 |
|
---|
1228 | # unplumb all vboxnet instances for non-remote installs
|
---|
1229 | unplumb_net
|
---|
1230 |
|
---|
1231 | # Stop our other daemons, non-fatal
|
---|
1232 | stop_process "VBoxNetDHCP"
|
---|
1233 | stop_process "VBoxNetNAT"
|
---|
1234 |
|
---|
1235 | # Stop VBoxSVC quickly using SIGUSR1
|
---|
1236 | procname="VBoxSVC"
|
---|
1237 | procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
|
---|
1238 | if test ! -z "$procpid" && test "$procpid" -ge 0; then
|
---|
1239 | kill -USR1 $procpid
|
---|
1240 |
|
---|
1241 | # Sleep a while and check if VBoxSVC is still running, if so fail uninstallation.
|
---|
1242 | sleep 2
|
---|
1243 | is_process_running "VBoxSVC"
|
---|
1244 | if test "$?" -eq 1; then
|
---|
1245 | errorprint "Cannot uninstall VirtualBox while VBoxSVC (pid $procpid) is still running."
|
---|
1246 | errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
|
---|
1247 | exit 1
|
---|
1248 | fi
|
---|
1249 |
|
---|
1250 | # Some VMs might still be alive after VBoxSVC as they poll less frequently before killing themselves
|
---|
1251 | # Just check for VBoxHeadless & VirtualBox frontends for now.
|
---|
1252 | is_process_running "VBoxHeadless"
|
---|
1253 | if test "$?" -eq 1; then
|
---|
1254 | errorprint "Cannot uninstall VirtualBox while VBoxHeadless is still running."
|
---|
1255 | errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
|
---|
1256 | exit 1
|
---|
1257 | fi
|
---|
1258 |
|
---|
1259 | is_process_running "VirtualBox"
|
---|
1260 | if test "$?" -eq 1; then
|
---|
1261 | errorprint "Cannot uninstall VirtualBox while any VM is still running."
|
---|
1262 | errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
|
---|
1263 | exit 1
|
---|
1264 | fi
|
---|
1265 | fi
|
---|
1266 |
|
---|
1267 | # Remove stuff installed for the Python bindings.
|
---|
1268 | if [ -r "$CONFIG_DIR/$CONFIG_FILES" ]; then
|
---|
1269 | rm -f `cat "$CONFIG_DIR/$CONFIG_FILES"` 2> /dev/null
|
---|
1270 | rm -f "$CONFIG_DIR/$CONFIG_FILES" 2> /dev/null
|
---|
1271 | rmdir "$CONFIG_DIR" 2> /dev/null
|
---|
1272 | fi
|
---|
1273 | }
|
---|
1274 |
|
---|
1275 |
|
---|
1276 | # postinstall()
|
---|
1277 | # !! failure is always fatal
|
---|
1278 | postinstall()
|
---|
1279 | {
|
---|
1280 | infoprint "Detected Solaris $HOST_OS_MAJORVERSION Version $HOST_OS_MINORVERSION"
|
---|
1281 |
|
---|
1282 | infoprint "Loading VirtualBox kernel modules..."
|
---|
1283 | install_drivers
|
---|
1284 |
|
---|
1285 | if test "$?" -eq 0; then
|
---|
1286 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
1287 | # nwam/dhcpagent fix
|
---|
1288 | nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
|
---|
1289 | nwambackupfile=$nwamfile.vbox
|
---|
1290 | if test -f "$nwamfile"; then
|
---|
1291 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
1292 |
|
---|
1293 | # add all vboxnet instances as static to nwam
|
---|
1294 | inst=0
|
---|
1295 | networkn=56
|
---|
1296 | while test "$inst" -ne 1; do
|
---|
1297 | echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
|
---|
1298 | inst=`expr $inst + 1`
|
---|
1299 | networkn=`expr $networkn + 1`
|
---|
1300 | done
|
---|
1301 | mv -f $nwambackupfile $nwamfile
|
---|
1302 | fi
|
---|
1303 |
|
---|
1304 | # plumb and configure vboxnet0 for non-remote installs
|
---|
1305 | if test "$REMOTEINST" -eq 0; then
|
---|
1306 | plumb_net
|
---|
1307 | fi
|
---|
1308 | fi
|
---|
1309 |
|
---|
1310 | if test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml" \
|
---|
1311 | || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml" \
|
---|
1312 | || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"\
|
---|
1313 | || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-autostart.xml"; then
|
---|
1314 | infoprint "Configuring services..."
|
---|
1315 | if test "$REMOTEINST" -eq 1; then
|
---|
1316 | subprint "Skipped for targeted installs."
|
---|
1317 | else
|
---|
1318 | # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
|
---|
1319 | # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
|
---|
1320 | # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
|
---|
1321 | $BIN_SVCADM restart svc:system/manifest-import:default
|
---|
1322 |
|
---|
1323 | # Start ZoneAccess service, other services are disabled by default.
|
---|
1324 | start_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default" \
|
---|
1325 | "/var/svc/log/application-virtualbox-zoneaccess:default.log"
|
---|
1326 | fi
|
---|
1327 | fi
|
---|
1328 |
|
---|
1329 | # Update mime and desktop databases to get the right menu entries
|
---|
1330 | # and icons. There is still some delay until the GUI picks it up,
|
---|
1331 | # but that cannot be helped.
|
---|
1332 | if test -d "$PKG_INSTALL_ROOT/usr/share/icons"; then
|
---|
1333 | infoprint "Installing MIME types and icons..."
|
---|
1334 | if test "$REMOTEINST" -eq 0; then
|
---|
1335 | /usr/bin/update-mime-database /usr/share/mime >/dev/null 2>&1
|
---|
1336 | /usr/bin/update-desktop-database -q 2>/dev/null
|
---|
1337 | else
|
---|
1338 | subprint "Skipped for targeted installs."
|
---|
1339 | fi
|
---|
1340 | fi
|
---|
1341 |
|
---|
1342 | if test -f "$VBOX_INSTALL_PATH/sdk/installer/vboxapisetup.py" || test -h "$VBOX_INSTALL_PATH/sdk/installer/vboxapisetup.py"; then
|
---|
1343 | # Install python bindings for non-remote installs
|
---|
1344 | if test "$REMOTEINST" -eq 0; then
|
---|
1345 | infoprint "Installing Python bindings..."
|
---|
1346 |
|
---|
1347 | # Loop over all usual suspect Python executable names and try
|
---|
1348 | # installing the VirtualBox API bindings. Needs to prevent
|
---|
1349 | # double installs which waste quite a bit of time.
|
---|
1350 | PYTHONS=""
|
---|
1351 | for p in python2.4 python2.5 python2.6 python2.7 python2 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9 python3.10 python3 python; do
|
---|
1352 | if [ "`$p -c 'import sys
|
---|
1353 | if sys.version_info >= (2, 4) and (sys.version_info < (3, 0) or sys.version_info >= (3, 3)):
|
---|
1354 | print(\"test\")' 2> /dev/null`" != "test" ]; then
|
---|
1355 | continue
|
---|
1356 | fi
|
---|
1357 | # Get python major/minor version, and skip if it was
|
---|
1358 | # already covered. Uses grep -F to avoid trouble with '.'
|
---|
1359 | # matching any char.
|
---|
1360 | pyvers="`$p -c 'import sys
|
---|
1361 | print("%s.%s" % (sys.version_info[0], sys.version_info[1]))' 2> /dev/null`"
|
---|
1362 | if echo "$PYTHONS" | /usr/xpg4/bin/grep -Fq ":$pyvers:"; then
|
---|
1363 | continue
|
---|
1364 | fi
|
---|
1365 | # Record which version will be installed. If it fails there
|
---|
1366 | # is no point trying with different executable/symlink
|
---|
1367 | # reporting the same version.
|
---|
1368 | PYTHONS="$PYTHONS:$pyvers:"
|
---|
1369 | install_python_bindings "$p" "Python $pyvers"
|
---|
1370 | done
|
---|
1371 | if [ -z "$PYTHONS" ]; then
|
---|
1372 | warnprint "Python (2.4 to 2.7 or 3.3 and later) unavailable, skipping bindings installation."
|
---|
1373 | fi
|
---|
1374 | else
|
---|
1375 | warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
|
---|
1376 | fi
|
---|
1377 | fi
|
---|
1378 |
|
---|
1379 | update_boot_archive
|
---|
1380 |
|
---|
1381 | return 0
|
---|
1382 | else
|
---|
1383 | errorprint "Failed to install drivers"
|
---|
1384 | exit 666
|
---|
1385 | fi
|
---|
1386 | return 1
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | # preremove([fatal])
|
---|
1390 | # failure: depends on [fatal]
|
---|
1391 | preremove()
|
---|
1392 | {
|
---|
1393 | fatal=$1
|
---|
1394 |
|
---|
1395 | cleanup_install "$fatal"
|
---|
1396 |
|
---|
1397 | remove_drivers "$fatal"
|
---|
1398 | if test "$?" -eq 0; then
|
---|
1399 | return 0;
|
---|
1400 | fi
|
---|
1401 | return 1
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 |
|
---|
1405 | # And it begins...
|
---|
1406 | if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
|
---|
1407 | BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
|
---|
1408 | BASEDIR_PKGOPT="-R $PKG_INSTALL_ROOT"
|
---|
1409 | REMOTEINST=1
|
---|
1410 | fi
|
---|
1411 | find_bins
|
---|
1412 | check_root
|
---|
1413 | check_isa
|
---|
1414 | check_zone
|
---|
1415 | get_sysinfo
|
---|
1416 |
|
---|
1417 |
|
---|
1418 | # Get command line options
|
---|
1419 | while test $# -gt 0;
|
---|
1420 | do
|
---|
1421 | case "$1" in
|
---|
1422 | --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
|
---|
1423 | drvop="$1"
|
---|
1424 | ;;
|
---|
1425 | --fatal)
|
---|
1426 | fatal="$FATALOP"
|
---|
1427 | ;;
|
---|
1428 | --silent)
|
---|
1429 | ISSILENT="$SILENTOP"
|
---|
1430 | ;;
|
---|
1431 | --ips)
|
---|
1432 | ISIPS="$IPSOP"
|
---|
1433 | ;;
|
---|
1434 | --altkerndir)
|
---|
1435 | # Use alternate kernel driver config folder (dev only)
|
---|
1436 | DIR_CONF="/usr/kernel/drv"
|
---|
1437 | ;;
|
---|
1438 | --sh-trace) # forwarded pkgadd -v
|
---|
1439 | set -x
|
---|
1440 | ;;
|
---|
1441 | --help)
|
---|
1442 | printusage
|
---|
1443 | exit 1
|
---|
1444 | ;;
|
---|
1445 | *)
|
---|
1446 | # Take a hard line on invalid options.
|
---|
1447 | errorprint "Invalid command line option: \"$1\""
|
---|
1448 | exit 1;
|
---|
1449 | ;;
|
---|
1450 | esac
|
---|
1451 | shift
|
---|
1452 | done
|
---|
1453 |
|
---|
1454 | case "$drvop" in
|
---|
1455 | --postinstall)
|
---|
1456 | check_module_arch
|
---|
1457 | postinstall
|
---|
1458 | ;;
|
---|
1459 | --preremove)
|
---|
1460 | preremove "$fatal"
|
---|
1461 | ;;
|
---|
1462 | --installdrivers)
|
---|
1463 | check_module_arch
|
---|
1464 | install_drivers
|
---|
1465 | ;;
|
---|
1466 | --removedrivers)
|
---|
1467 | remove_drivers "$fatal"
|
---|
1468 | ;;
|
---|
1469 | --setupdrivers)
|
---|
1470 | remove_drivers "$fatal"
|
---|
1471 | infoprint "Installing VirtualBox drivers:"
|
---|
1472 | install_drivers
|
---|
1473 | ;;
|
---|
1474 | *)
|
---|
1475 | printusage
|
---|
1476 | exit 1
|
---|
1477 | esac
|
---|
1478 |
|
---|
1479 | exit "$?"
|
---|
1480 |
|
---|