VirtualBox

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

Last change on this file since 78335 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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