VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/vboxconfig.sh@ 58026

Last change on this file since 58026 was 58026, checked in by vboxsync, 9 years ago

Solaris/Installer: vboxconfig.sh, fix typo.

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