VirtualBox

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

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

Solaris/Installer: Detect all unofficial Solaris distros as S11 snv_151. Added support for vboxusb touch file to force installing host USB support.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 46.0 KB
Line 
1#!/bin/sh
2# $Id: vboxconfig.sh 58117 2015-10-08 14:54:33Z 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_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/[email protected],5.11-0.161:20110315T070332Z"
267 # or "pkg://solaris/system/[email protected],5.11-5.12.0.0.0.4.1:20120908T030246Z"
268 # or "pkg://solaris/system/[email protected],5.11-0.175.0.0.0.1.0:20111012T032837Z"
269 # or "pkg://solaris/system/[email protected]: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 "$STR_KERN_MAJOR" = "5.12"; then
278 HOST_OS_MAJORVERSION="12"
279 elif test "$STR_KERN_MAJOR" = "0.5.11" || test "$STR_KERN_MAJOR" = "5.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/[email protected]: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 "$HOST_OS_MAJORVERSION" = "5.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 "$HOST_OS_MAJORVERSION" != "5.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 "$REMOTE_S10" = "SUNWckr"; 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 "$currentzone" != "global"; 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 "$currentisa" = "i86xpv"; 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 "$cputype" != "amd64" && test "$cputype" != "i386"; 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 "$nullop" = "$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 "$nullop" = "$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 "$fatal" = "$FATALOP"; then
477 exit 1
478 fi
479 return 1
480 elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
481 subprint "Added: $moddesc driver"
482 fi
483 return 0
484}
485
486# rem_driver(modname, moddesc, [fatal])
487# failure: depends on [fatal]
488rem_driver()
489{
490 if test -z "$1" || test -z "$2"; then
491 errorprint "missing argument to rem_driver()"
492 exit 1
493 fi
494
495 modname=$1
496 moddesc=$2
497 fatal=$3
498
499 module_added $modname
500 if test "$?" -eq 0; then
501 UPDATEBOOTARCHIVE=1
502 if test "$ISIPS" != "$IPSOP"; then
503 $BIN_REMDRV $BASEDIR_OPT $modname
504 else
505 $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
506 fi
507 # for remote installs, don't bother with return values of rem_drv
508 if test $? -eq 0; then
509 subprint "Removed: $moddesc module"
510 return 0
511 else
512 subprint "Removing: $moddesc ...FAILED!"
513 if test "$fatal" = "$FATALOP"; then
514 exit 1
515 fi
516 return 1
517 fi
518 fi
519}
520
521# unload_module(modname, moddesc, retry, [fatal])
522# failure: fatal
523unload_module()
524{
525 if test -z "$1" || test -z "$2"; then
526 errorprint "missing argument to unload_module()"
527 exit 1
528 fi
529
530 # No-OP for non-root installs
531 if test "$REMOTEINST" -eq 1; then
532 return 0
533 fi
534
535 modname=$1
536 moddesc=$2
537 retry=$3
538 fatal=$4
539 modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
540 if test -n "$modid"; then
541 $BIN_MODUNLOAD -i $modid
542 if test $? -eq 0; then
543 subprint "Unloaded: $moddesc module"
544 else
545 #
546 # Hack for vboxdrv. Delayed removing when VMM thread-context hooks are used.
547 # Our automated tests are probably too quick... Fix properly later.
548 #
549 result=$?
550 if test "$retry" -eq 1; then
551 cmax=15
552 cslept=0
553 while test "$result" -ne 0;
554 do
555 subprint "Unloading: $moddesc module ...FAILED! Busy? Retrying in 3 seconds..."
556 sleep 3
557 cslept=`expr $cslept + 3`
558 if test "$cslept" -ge "$cmax"; then
559 break
560 fi
561 $BIN_MODUNLOAD -i $modid
562 result=$?
563 done
564 fi
565
566 if test "$result" -ne 0; then
567 subprint "Unloading: $moddesc module ...FAILED!"
568 if test "$fatal" = "$FATALOP"; then
569 exit 1
570 fi
571 else
572 subprint "Unloaded: $moddesc module"
573 fi
574 return 1
575 fi
576 fi
577 return 0
578}
579
580# load_module(modname, moddesc, [fatal])
581# pass "drv/modname" or "misc/vbi" etc.
582# failure: fatal
583load_module()
584{
585 if test -z "$1" || test -z "$2"; then
586 errorprint "missing argument to load_module()"
587 exit 1
588 fi
589
590 # No-OP for non-root installs
591 if test "$REMOTEINST" -eq 1; then
592 return 0
593 fi
594
595 modname=$1
596 moddesc=$2
597 fatal=$3
598 $BIN_MODLOAD -p $modname
599 if test $? -eq 0; then
600 subprint "Loaded: $moddesc module"
601 return 0
602 else
603 subprint "Loading: $moddesc ...FAILED!"
604 if test "$fatal" = "$FATALOP"; then
605 exit 1
606 fi
607 return 1
608 fi
609}
610
611load_vboxflt()
612{
613 if test -f "$DIR_CONF/vboxflt.conf"; then
614 add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
615 load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
616 else
617 # For custom pkgs that optionally ship this module, let's not fail but just warn
618 warnprint "$DESC_VBOXFLT installation requested but not shipped in this package."
619 fi
620}
621
622load_vboxbow()
623{
624 if test -f "$DIR_CONF/vboxbow.conf"; then
625 add_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
626 load_module "drv/$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
627 else
628 # For custom pkgs that optionally ship this module, let's not fail but just warn
629 warnprint "$DESC_VBOXBOW installation requested but not shipped in this package."
630 fi
631}
632
633# install_drivers()
634# !! failure is always fatal
635install_drivers()
636{
637 if test -f "$DIR_CONF/vboxdrv.conf"; then
638 if test -n "_HARDENED_"; then
639 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys','vboxdrvu 0666 root sys'"
640 else
641 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys','vboxdrvu 0666 root sys'"
642 fi
643 load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
644 else
645 errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
646 return 1
647 fi
648
649 ## Add vboxdrv to devlink.tab (KEEP TABS!)
650 if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
651 sed -e '/name=vboxdrv/d' -e '/name=vboxdrvu/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
652 echo "type=ddi_pseudo;name=vboxdrv;minor=vboxdrv \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
653 echo "type=ddi_pseudo;name=vboxdrv;minor=vboxdrvu \M0" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
654 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
655 else
656 errorprint "Missing $PKG_INSTALL_ROOT/etc/devlink.tab, aborting install"
657 return 1
658 fi
659
660 # Create the device link for non-remote installs (not really relevant any more)
661 if test "$REMOTEINST" -eq 0; then
662 /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
663 if test $? -ne 0 || test ! -h "/dev/vboxdrv" || test ! -h "/dev/vboxdrvu" ; then
664 errorprint "Failed to create device link for $MOD_VBOXDRV."
665 exit 1
666 fi
667 fi
668
669 # Load VBoxNetAdp
670 if test -f "$DIR_CONF/vboxnet.conf"; then
671 add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
672 load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
673 fi
674
675 # If both vboxinst_vboxbow and vboxinst_vboxflt exist, bail.
676 if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt" && test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
677 errorprint "Force-install files '$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt' and '$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow' both exist."
678 errorprint "Cannot load $DESC_VBOXFLT and $DESC_VBOXBOW drivers at the same time."
679 return 1
680 fi
681
682 # If the force-install files exists, install blindly
683 if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt"; then
684 subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxflt."
685 load_vboxflt
686 elif test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
687 subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxbow."
688 load_vboxbow
689 else
690 # If host is S10 or S11 (< snv_159) or vboxbow isn't shipped, then load vboxflt
691 if test "$HOST_OS_MAJORVERSION" -eq 10 \
692 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -lt 159) \
693 || test ! -f "$DIR_CONF/vboxbow.conf"; then
694 load_vboxflt
695 else
696 # For S11 snv_159+ load vboxbow
697 load_vboxbow
698 fi
699 fi
700
701 # Load VBoxUSBMon, VBoxUSB
702 try_vboxusb="no"
703 if test -f "$DIR_CONF/vboxusbmon.conf"; then
704 if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxusb"; then
705 subprint "Detected: Force-load file $PKG_INSTALL_ROOT/etc/vboxinst_vboxusb."
706 try_vboxusb="yes"
707 else
708 # For VirtualBox 3.1 the new USB code requires Nevada > 123 i.e. S12+ or S11 b124+
709 if test "$HOST_OS_MAJORVERSION" -gt 11 \
710 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 123); then
711 try_vboxusb="yes"
712 else
713 warnprint "Solaris 11 build 124 or higher required for USB support. Skipped installing USB support."
714 fi
715 fi
716 fi
717 if test "$try_vboxusb" = "yes"; then
718 # Add a group "vboxuser" (8-character limit) for USB access.
719 # All users which need host USB-passthrough support will have to be added to this group.
720 groupadd vboxuser >/dev/null 2>&1
721
722 add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
723 load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
724
725 chown root:vboxuser "/devices/pseudo/vboxusbmon@0:vboxusbmon"
726
727 # Add vboxusbmon to devlink.tab
728 sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
729 echo "type=ddi_pseudo;name=vboxusbmon \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
730 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
731
732 # Create the device link for non-remote installs
733 if test "$REMOTEINST" -eq 0; then
734 /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
735 if test $? -ne 0; then
736 errorprint "Failed to create device link for $MOD_VBOXUSBMON."
737 exit 1
738 fi
739 fi
740
741 # Add vboxusb if present
742 # This driver is special, we need it in the boot-archive but since there is no
743 # USB device to attach to now (it's done at runtime) it will fail to attach so
744 # redirect attaching failure output to /dev/null
745 if test -f "$DIR_CONF/vboxusb.conf"; then
746 add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
747 load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
748 fi
749 fi
750
751 return $?
752}
753
754# remove_drivers([fatal])
755# failure: depends on [fatal]
756remove_drivers()
757{
758 fatal=$1
759
760 # Remove vboxdrv[u] from devlink.tab
761 if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
762 devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxdrv`
763 if test -n "$devlinkfound"; then
764 sed -e '/name=vboxdrv/d' -e '/name=vboxdrvu/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
765 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
766 fi
767
768 # Remove vboxusbmon from devlink.tab
769 devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxusbmon`
770 if test -n "$devlinkfound"; then
771 sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
772 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
773 fi
774 fi
775
776 unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" 0 "$fatal"
777 rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
778
779 unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" 0 "$fatal"
780 rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
781
782 unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" 0 "$fatal"
783 rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
784
785 unload_module "$MOD_VBOXBOW" "$DESC_VBOXBOW" 0 "$fatal"
786 rem_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
787
788 unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" 0 "$fatal"
789 rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
790
791 unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" 1 "$fatal"
792 rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
793
794 # remove devlinks
795 if test -h "$PKG_INSTALL_ROOT/dev/vboxdrv" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrv"; then
796 rm -f "$PKG_INSTALL_ROOT/dev/vboxdrv"
797 fi
798 if test -h "$PKG_INSTALL_ROOT/dev/vboxdrvu" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrvu"; then
799 rm -f "$PKG_INSTALL_ROOT/dev/vboxdrvu"
800 fi
801 if test -h "$PKG_INSTALL_ROOT/dev/vboxusbmon" || test -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"; then
802 rm -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"
803 fi
804
805 # unpatch nwam/dhcpagent fix
806 nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
807 nwambackupfile=$nwamfile.vbox
808 if test -f "$nwamfile"; then
809 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
810 mv -f $nwambackupfile $nwamfile
811 fi
812
813 # remove netmask configuration
814 if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
815 nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
816 else
817 nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
818 fi
819 nmaskbackupfile=$nmaskfile.vbox
820 if test -f "$nmaskfile"; then
821 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
822 mv -f $nmaskbackupfile $nmaskfile
823 fi
824
825 if test $UPDATEBOOTARCHIVE -eq 1; then
826 update_boot_archive
827 fi
828
829 return 0
830}
831
832# install_python_bindings(pythonbin)
833# remarks: changes pwd
834# failure: non fatal
835install_python_bindings()
836{
837 # The python binary might not be there, so just exit silently
838 if test -z "$1"; then
839 return 0
840 fi
841
842 if test -z "$2"; then
843 errorprint "missing argument to install_python_bindings"
844 exit 1
845 fi
846
847 pythonbin=$1
848 pythondesc=$2
849 if test -x "$pythonbin"; then
850 # check if python has working distutils
851 $pythonbin -c "from distutils.core import setup" > /dev/null 2>&1
852 if test "$?" -ne 0; then
853 subprint "Skipped: $pythondesc install is unusable"
854 return 0
855 fi
856
857 VBOX_INSTALL_PATH="$DIR_VBOXBASE"
858 export VBOX_INSTALL_PATH
859 cd $DIR_VBOXBASE/sdk/installer
860 $pythonbin ./vboxapisetup.py install > /dev/null
861 if test "$?" -eq 0; then
862 subprint "Installed: Bindings for $pythondesc"
863 fi
864 return 0
865 fi
866 return 1
867}
868
869# is_process_running(processname)
870# returns 1 if the process is running, 0 otherwise
871is_process_running()
872{
873 if test -z "$1"; then
874 errorprint "missing argument to is_process_running()"
875 exit 1
876 fi
877
878 procname="$1"
879 $BIN_PGREP "$procname" > /dev/null 2>&1
880 if test "$?" -eq 0; then
881 return 1
882 fi
883 return 0
884}
885
886
887# stop_process(processname)
888# failure: depends on [fatal]
889stop_process()
890{
891 if test -z "$1"; then
892 errorprint "missing argument to stop_process()"
893 exit 1
894 fi
895
896 procname="$1"
897 is_process_running "$procname"
898 if test "$?" -eq 1; then
899 $BIN_PKILL "$procname"
900 sleep 2
901 is_process_running "$procname"
902 if test "$?" -eq 1; then
903 subprint "Terminating: $procname ...FAILED!"
904 if test "$fatal" = "$FATALOP"; then
905 exit 1
906 fi
907 else
908 subprint "Terminated: $procname"
909 fi
910 fi
911}
912
913# start_service(servicename, shortFMRI pretty printing, full FMRI, log-file path)
914# failure: non-fatal
915start_service()
916{
917 if test -z "$1" || test -z "$2" || test -z "$3" || test -z "$4"; then
918 errorprint "missing argument to enable_service()"
919 exit 1
920 fi
921
922 # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
923 # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
924 # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
925 cmax=32
926 cslept=0
927 success=0
928
929 $BIN_SVCS "$3" >/dev/null 2>&1
930 while test $? -ne 0;
931 do
932 sleep 1
933 cslept=`expr $cslept + 1`
934 if test "$cslept" -eq "$cmax"; then
935 success=1
936 break
937 fi
938 $BIN_SVCS "$3" >/dev/null 2>&1
939 done
940 if test "$success" -eq 0; then
941 $BIN_SVCADM enable -s "$3"
942 if test "$?" -eq 0; then
943 subprint "Enabled: $1"
944 return 0
945 else
946 warnprint "Enabling $1 ...FAILED."
947 warnprint "Refer $4 for details."
948 fi
949 else
950 warnprint "Importing $1 ...FAILED."
951 warnprint "Refer /var/svc/log/system-manifest-import:default.log for details."
952 fi
953 return 1
954}
955
956
957# stop_service(servicename, shortFMRI-suitable for grep, full FMRI)
958# failure: non fatal
959stop_service()
960{
961 if test -z "$1" || test -z "$2" || test -z "$3"; then
962 errorprint "missing argument to stop_service()"
963 exit 1
964 fi
965 servicefound=`$BIN_SVCS -H "$2" 2>/dev/null | grep '^online'`
966 if test ! -z "$servicefound"; then
967 $BIN_SVCADM disable -s "$3"
968 # Don't delete the manifest, this is handled by the manifest class action
969 # $BIN_SVCCFG delete "$3"
970 if test "$?" -eq 0; then
971 subprint "Disabled: $1"
972 else
973 subprint "Disabling: $1 ...ERROR(S)."
974 fi
975 fi
976}
977
978
979# plumb vboxnet0 instance
980# failure: non fatal
981plumb_net()
982{
983 # S11 175a renames vboxnet0 as 'netX', undo this and rename it back (S12+ or S11 b175+)
984 if test "$HOST_OS_MAJORVERSION" -gt 11 || (test "$HOST_OS_MAJORVERSION" -eq 11 && test "$HOST_OS_MINORVERSION" -gt 174); then
985 vanityname=`dladm show-phys -po link,device | grep vboxnet0 | cut -f1 -d':'`
986 if test $? -eq 0 && test ! -z "$vanityname" && test "$vanityname" != "vboxnet0"; then
987 dladm rename-link "$vanityname" vboxnet0
988 if test $? -ne 0; then
989 errorprint "Failed to rename vanity interface ($vanityname) to vboxnet0"
990 fi
991 fi
992 fi
993
994 # use ipadm for Solaris 12 and newer
995 if test "$HOST_OS_MAJORVERSION" -ge 12; then
996 $BIN_IPADM create-ip vboxnet0
997 if test "$?" -eq 0; then
998 $BIN_IPADM create-addr -T static -a local="192.168.56.1/24" "vboxnet0/v4addr"
999 if test "$?" -eq 0; then
1000 subprint "Configured: NetAdapter 'vboxnet0'"
1001 else
1002 warnprint "Failed to create local address for vboxnet0!"
1003 fi
1004 else
1005 warnprint "Failed to create IP instance for vboxnet0!"
1006 fi
1007 else
1008 $BIN_IFCONFIG vboxnet0 plumb
1009 $BIN_IFCONFIG vboxnet0 up
1010 if test "$?" -eq 0; then
1011 $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
1012
1013 # /etc/netmasks is a symlink, older installers replaced this with
1014 # a copy of the actual file, repair that behaviour here.
1015 recreatelink=0
1016 if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
1017 nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
1018 else
1019 nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
1020 recreatelink=1
1021 fi
1022
1023 # add the netmask to stay persistent across host reboots
1024 nmaskbackupfile=$nmaskfile.vbox
1025 if test -f $nmaskfile; then
1026 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
1027
1028 if test $recreatelink -eq 1; then
1029 # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
1030 anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
1031 if test ! -z "$anydiff"; then
1032 # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
1033 recreatelink=2
1034 fi
1035 fi
1036
1037 echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
1038 inst=0
1039 networkn=56
1040 while test $inst -ne 1; do
1041 echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
1042 inst=`expr $inst + 1`
1043 networkn=`expr $networkn + 1`
1044 done
1045 echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
1046 mv -f $nmaskbackupfile $nmaskfile
1047
1048 # Recreate /etc/netmasks as a link if necessary
1049 if test $recreatelink -eq 1; then
1050 cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
1051 ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
1052 elif test $recreatelink -eq 2; then
1053 warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
1054 warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
1055 warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
1056 warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
1057 warnprint "symlink to /etc/inet/netmasks. Please resolve this manually"
1058 warnprint "by updating /etc/inet/netmasks and creating /etc/netmasks as a"
1059 warnprint "symlink to /etc/inet/netmasks"
1060 fi
1061 fi
1062 else
1063 # Should this be fatal?
1064 warnprint "Failed to bring up vboxnet0!"
1065 fi
1066 fi
1067}
1068
1069
1070# unplumb all vboxnet instances
1071# failure: fatal
1072unplumb_net()
1073{
1074 inst=0
1075 # use ipadm for Solaris 12 and newer
1076 if test "$HOST_OS_MAJORVERSION" -ge 12; then
1077 while test $inst -ne $MOD_VBOXNET_INST; do
1078 vboxnetup=`$BIN_IPADM show-addr -p -o addrobj vboxnet$inst >/dev/null 2>&1`
1079 if test "$?" -eq 0; then
1080 $BIN_IPADM delete-addr vboxnet$inst/v4addr
1081 $BIN_IPADM delete-ip vboxnet$inst
1082 if test "$?" -ne 0; then
1083 errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be removed (probably in use)."
1084 if test "$fatal" = "$FATALOP"; then
1085 exit 1
1086 fi
1087 fi
1088 fi
1089
1090 inst=`expr $inst + 1`
1091 done
1092 else
1093 inst=0
1094 while test $inst -ne $MOD_VBOXNET_INST; do
1095 vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
1096 if test "$?" -eq 0; then
1097 $BIN_IFCONFIG vboxnet$inst unplumb
1098 if test "$?" -ne 0; then
1099 errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
1100 if test "$fatal" = "$FATALOP"; then
1101 exit 1
1102 fi
1103 fi
1104 fi
1105
1106 # unplumb vboxnet0 ipv6
1107 vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
1108 if test "$?" -eq 0; then
1109 $BIN_IFCONFIG vboxnet$inst inet6 unplumb
1110 if test "$?" -ne 0; then
1111 errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
1112 if test "$fatal" = "$FATALOP"; then
1113 exit 1
1114 fi
1115 fi
1116 fi
1117
1118 inst=`expr $inst + 1`
1119 done
1120 fi
1121}
1122
1123
1124# cleanup_install([fatal])
1125# failure: depends on [fatal]
1126cleanup_install()
1127{
1128 fatal=$1
1129
1130 # No-Op for remote installs
1131 if test "$REMOTEINST" -eq 1; then
1132 return 0
1133 fi
1134
1135 # stop the services
1136 stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
1137 stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
1138 stop_service "Autostart service" "virtualbox/autostart" "svc:/application/virtualbox/autostart:default"
1139 stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
1140
1141 # DEBUG x4600b: verify that the ZoneAccess process is really gone
1142 is_process_running "VBoxZoneAccess"
1143 if test "$?" -eq 1; then
1144 warnprint "VBoxZoneAccess is alive despite its service being dead. Killing..."
1145 stop_process "VBoxZoneAccess"
1146 fi
1147
1148 # unplumb all vboxnet instances for non-remote installs
1149 unplumb_net
1150
1151 # Stop our other daemons, non-fatal
1152 stop_process "VBoxNetDHCP"
1153 stop_process "VBoxNetNAT"
1154
1155 # Stop VBoxSVC quickly using SIGUSR1
1156 procname="VBoxSVC"
1157 procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
1158 if test ! -z "$procpid" && test "$procpid" -ge 0; then
1159 kill -USR1 $procpid
1160
1161 # Sleep a while and check if VBoxSVC is still running, if so fail uninstallation.
1162 sleep 2
1163 is_process_running "VBoxSVC"
1164 if test "$?" -eq 1; then
1165 errorprint "Cannot uninstall VirtualBox while VBoxSVC (pid $procpid) is still running."
1166 errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
1167 exit 1
1168 fi
1169
1170 # Some VMs might still be alive after VBoxSVC as they poll less frequently before killing themselves
1171 # Just check for VBoxHeadless & VirtualBox frontends for now.
1172 is_process_running "VBoxHeadless"
1173 if test "$?" -eq 1; then
1174 errorprint "Cannot uninstall VirtualBox while VBoxHeadless is still running."
1175 errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
1176 exit 1
1177 fi
1178
1179 is_process_running "VirtualBox"
1180 if test "$?" -eq 1; then
1181 errorprint "Cannot uninstall VirtualBox while any VM is still running."
1182 errorprint "Please shutdown all VMs and VirtualBox frontends before uninstalling VirtualBox."
1183 exit 1
1184 fi
1185 fi
1186}
1187
1188
1189# postinstall()
1190# !! failure is always fatal
1191postinstall()
1192{
1193 infoprint "Detected Solaris $HOST_OS_MAJORVERSION Version $HOST_OS_MINORVERSION"
1194 infoprint "Loading VirtualBox kernel modules..."
1195 install_drivers
1196
1197 if test "$?" -eq 0; then
1198 if test -f "$DIR_CONF/vboxnet.conf"; then
1199 # nwam/dhcpagent fix
1200 nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
1201 nwambackupfile=$nwamfile.vbox
1202 if test -f "$nwamfile"; then
1203 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
1204
1205 # add all vboxnet instances as static to nwam
1206 inst=0
1207 networkn=56
1208 while test $inst -ne 1; do
1209 echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
1210 inst=`expr $inst + 1`
1211 networkn=`expr $networkn + 1`
1212 done
1213 mv -f $nwambackupfile $nwamfile
1214 fi
1215
1216 # plumb and configure vboxnet0 for non-remote installs
1217 if test "$REMOTEINST" -eq 0; then
1218 plumb_net
1219 fi
1220 fi
1221
1222 if test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml" \
1223 || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml" \
1224 || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"\
1225 || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-autostart.xml"; then
1226 infoprint "Configuring services..."
1227 if test "$REMOTEINST" -eq 1; then
1228 subprint "Skipped for targetted installs."
1229 else
1230 # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
1231 # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
1232 # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
1233 $BIN_SVCADM restart svc:system/manifest-import:default
1234
1235 # Start ZoneAccess service, other services are disabled by default.
1236 start_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default" \
1237 "/var/svc/log/application-virtualbox-zoneaccess:default.log"
1238 fi
1239 fi
1240
1241 # Update mime and desktop databases to get the right menu entries
1242 # and icons. There is still some delay until the GUI picks it up,
1243 # but that cannot be helped.
1244 if test -d "$PKG_INSTALL_ROOT/usr/share/icons"; then
1245 infoprint "Installing MIME types and icons..."
1246 if test "$REMOTEINST" -eq 0; then
1247 /usr/bin/update-mime-database /usr/share/mime >/dev/null 2>&1
1248 /usr/bin/update-desktop-database -q 2>/dev/null
1249 else
1250 subprint "Skipped for targetted installs."
1251 fi
1252 fi
1253
1254 # Install python bindings for non-remote installs
1255 if test "$REMOTEINST" -eq 0; then
1256 if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
1257 PYTHONBIN=`which python 2> /dev/null`
1258 if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
1259 infoprint "Installing Python bindings..."
1260
1261 INSTALLEDIT=1
1262 PYTHONBIN=`which python2.4 2>/dev/null`
1263 install_python_bindings "$PYTHONBIN" "Python 2.4"
1264 if test "$?" -eq 0; then
1265 INSTALLEDIT=0
1266 fi
1267 PYTHONBIN=`which python2.5 2>/dev/null`
1268 install_python_bindings "$PYTHONBIN" "Python 2.5"
1269 if test "$?" -eq 0; then
1270 INSTALLEDIT=0
1271 fi
1272 PYTHONBIN=`which python2.6 2>/dev/null`
1273 install_python_bindings "$PYTHONBIN" "Python 2.6"
1274 if test "$?" -eq 0; then
1275 INSTALLEDIT=0
1276 fi
1277
1278 # remove files installed by Python build
1279 rm -rf $DIR_VBOXBASE/sdk/installer/build
1280
1281 if test "$INSTALLEDIT" -ne 0; then
1282 warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
1283 warnprint "Skipped installing the Python bindings."
1284 fi
1285 else
1286 warnprint "Python not found, skipped installed Python bindings."
1287 fi
1288 fi
1289 else
1290 warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
1291 fi
1292
1293 update_boot_archive
1294
1295 return 0
1296 else
1297 errorprint "Failed to install drivers"
1298 exit 666
1299 fi
1300 return 1
1301}
1302
1303# preremove([fatal])
1304# failure: depends on [fatal]
1305preremove()
1306{
1307 fatal=$1
1308
1309 cleanup_install "$fatal"
1310
1311 remove_drivers "$fatal"
1312 if test "$?" -eq 0; then
1313 return 0;
1314 fi
1315 return 1
1316}
1317
1318
1319# And it begins...
1320if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
1321 BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
1322 BASEDIR_PKGOPT="-R $PKG_INSTALL_ROOT"
1323 REMOTEINST=1
1324fi
1325find_bins
1326check_root
1327check_isa
1328check_zone
1329get_sysinfo
1330
1331
1332# Get command line options
1333while test $# -gt 0;
1334do
1335 case "$1" in
1336 --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
1337 drvop="$1"
1338 ;;
1339 --fatal)
1340 fatal="$FATALOP"
1341 ;;
1342 --silent)
1343 ISSILENT="$SILENTOP"
1344 ;;
1345 --ips)
1346 ISIPS="$IPSOP"
1347 ;;
1348 --altkerndir)
1349 # Use alternate kernel driver config folder (dev only)
1350 DIR_CONF="/usr/kernel/drv"
1351 ;;
1352 --sh-trace) # forwarded pkgadd -v
1353 set -x
1354 ;;
1355 --help)
1356 printusage
1357 exit 1
1358 ;;
1359 *)
1360 # Take a hard line on invalid options.
1361 errorprint "Invalid command line option: \"$1\""
1362 exit 1;
1363 ;;
1364 esac
1365 shift
1366done
1367
1368case "$drvop" in
1369--postinstall)
1370 check_module_arch
1371 postinstall
1372 ;;
1373--preremove)
1374 preremove "$fatal"
1375 ;;
1376--installdrivers)
1377 check_module_arch
1378 install_drivers
1379 ;;
1380--removedrivers)
1381 remove_drivers "$fatal"
1382 ;;
1383--setupdrivers)
1384 remove_drivers "$fatal"
1385 infoprint "Installing VirtualBox drivers:"
1386 install_drivers
1387 ;;
1388*)
1389 printusage
1390 exit 1
1391esac
1392
1393exit "$?"
1394
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