VirtualBox

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

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

Solaris/Installer: Another S12 fix.

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