VirtualBox

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

Last change on this file since 50926 was 50788, checked in by vboxsync, 11 years ago

Installer/solaris: For debugging stale VBoxZoneAccess service hanging about.

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