VirtualBox

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

Last change on this file since 47786 was 47489, checked in by vboxsync, 11 years ago

Solaris/Installer: fix recent breakage in vboxconfig.sh.

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