VirtualBox

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

Last change on this file since 62148 was 61918, checked in by vboxsync, 8 years ago

Installer: Solaris: Install legacy libraries links only for solaris10. Also install the links early so that when vbox services are invoked dependencies are already resolved.

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