VirtualBox

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

最後變更 在這個檔案從50519是 50519,由 vboxsync 提交於 11 年 前

Solaris/Installer: comment nit.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette