VirtualBox

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

Last change on this file since 37790 was 37790, checked in by vboxsync, 13 years ago

Solaris/Installer: typo fix.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 32.5 KB
Line 
1#!/bin/sh
2# $Id: vboxconfig.sh 37790 2011-07-06 09:12:21Z vboxsync $
3
4#
5# VirtualBox Configuration Script, Solaris host.
6#
7# Copyright (C) 2009-2010 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17
18# Never use exit 2 or exit 20 etc., the return codes are used in
19# SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
20
21LANG=C
22export LANG
23
24# S10 or OpenSoalris
25HOST_OS_MAJORVERSION=`uname -r`
26# Which OpenSolaris version (snv_xxx or oi_xxx)?
27HOST_OS_MINORVERSION=`uname -v | egrep 'snv|oi' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9]//"`
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_IFCONFIG=/sbin/ifconfig
45BIN_SVCS=/usr/bin/svcs
46BIN_ID=/usr/bin/id
47BIN_PKILL=/usr/bin/pkill
48
49# "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
50MOD_VBOXDRV=vboxdrv
51DESC_VBOXDRV="Host"
52
53MOD_VBOXNET=vboxnet
54DESC_VBOXNET="NetAdapter"
55MOD_VBOXNET_INST=32
56
57MOD_VBOXFLT=vboxflt
58DESC_VBOXFLT="NetFilter (STREAMS)"
59
60MOD_VBOXBOW=vboxbow
61DESC_VBOXBOW="NetFilter (Crossbow)"
62
63# No Separate VBI since (3.1)
64#MOD_VBI=vbi
65#DESC_VBI="Kernel Interface"
66
67MOD_VBOXUSBMON=vboxusbmon
68DESC_VBOXUSBMON="USBMonitor"
69
70MOD_VBOXUSB=vboxusb
71DESC_VBOXUSB="USB"
72
73UPDATEBOOTARCHIVE=0
74REMOTEINST=0
75FATALOP=fatal
76NULLOP=nulloutput
77SILENTOP=silent
78IPSOP=ips
79ISSILENT=
80ISIPS=
81
82infoprint()
83{
84 if test "$ISSILENT" != "$SILENTOP"; then
85 echo 1>&2 "$1"
86 fi
87}
88
89subprint()
90{
91 if test "$ISSILENT" != "$SILENTOP"; then
92 echo 1>&2 " - $1"
93 fi
94}
95
96warnprint()
97{
98 if test "$ISSILENT" != "$SILENTOP"; then
99 echo 1>&2 " * Warning!! $1"
100 fi
101}
102
103errorprint()
104{
105 echo 1>&2 "## $1"
106}
107
108helpprint()
109{
110 echo 1>&2 "$1"
111}
112
113printusage()
114{
115 helpprint "VirtualBox Configuration Script"
116 helpprint "usage: $0 <operation> [options]"
117 helpprint
118 helpprint "<operation> must be one of the following:"
119 helpprint " --postinstall Perform full post installation procedure"
120 helpprint " --preremove Perform full pre remove procedure"
121 helpprint " --installdrivers Only install the drivers"
122 helpprint " --removedrivers Only remove the drivers"
123 helpprint " --setupdrivers Setup drivers, reloads existing drivers"
124 helpprint
125 helpprint "[options] are one or more of the following:"
126 helpprint " --silent Silent mode"
127 helpprint " --fatal Don't continue on failure (required for postinstall)"
128 helpprint " --ips This is an IPS package postinstall/preremove"
129 helpprint " --altkerndir Use /usr/kernel/drv as the driver directory"
130 helpprint
131}
132
133# find_bin_path()
134# !! failure is always fatal
135find_bin_path()
136{
137 if test -z "$1"; then
138 errorprint "missing argument to find_bin_path()"
139 exit 1
140 fi
141
142 binfilename=`basename $1`
143 binfilepath=`which $binfilename 2> /dev/null`
144 if test -x "$binfilepath"; then
145 echo "$binfilepath"
146 return 0
147 else
148 errorprint "$1 missing or is not an executable"
149 exit 1
150 fi
151}
152
153# find_bins()
154# !! failure is always fatal
155find_bins()
156{
157 # Search only for binaries that might be in different locations
158 if test ! -x "$BIN_ID"; then
159 BIN_ID=`find_bin_path "$BIN_ID"`
160 fi
161
162 if test ! -x "$BIN_ADDDRV"; then
163 BIN_ADDDRV=`find_bin_path "$BIN_ADDDRV"`
164 fi
165
166 if test ! -x "$BIN_REMDRV"; then
167 BIN_REMDRV=`find_bin_path "$BIN_REMDRV"`
168 fi
169
170 if test ! -x "$BIN_MODLOAD"; then
171 BIN_MODLOAD=`check_bin_path "$BIN_MODLOAD"`
172 fi
173
174 if test ! -x "$BIN_MODUNLOAD"; then
175 BIN_MODUNLOAD=`find_bin_path "$BIN_MODUNLOAD"`
176 fi
177
178 if test ! -x "$BIN_MODINFO"; then
179 BIN_MODINFO=`find_bin_path "$BIN_MODINFO"`
180 fi
181
182 if test ! -x "$BIN_DEVFSADM"; then
183 BIN_DEVFSADM=`find_bin_path "$BIN_DEVFSADM"`
184 fi
185
186 if test ! -x "$BIN_BOOTADM"; then
187 BIN_BOOTADM=`find_bin_path "$BIN_BOOTADM"`
188 fi
189
190 if test ! -x "$BIN_SVCADM"; then
191 BIN_SVCADM=`find_bin_path "$BIN_SVCADM"`
192 fi
193
194 if test ! -x "$BIN_SVCCFG"; then
195 BIN_SVCCFG=`find_bin_path "$BIN_SVCCFG"`
196 fi
197
198 if test ! -x "$BIN_SVCS"; then
199 BIN_SVCS=`find_bin_path "$BIN_SVCS"`
200 fi
201
202 if test ! -x "$BIN_IFCONFIG"; then
203 BIN_IFCONFIG=`find_bin_path "$BIN_IFCONFIG"`
204 fi
205
206 if test ! -x "$BIN_PKILL"; then
207 BIN_PKILL=`find_bin_path "$BIN_PKILL"`
208 fi
209}
210
211# check_root()
212# !! failure is always fatal
213check_root()
214{
215 # Don't use "-u" option as some id binaries don't support it, instead
216 # rely on "uid=101(username) gid=10(groupname) groups=10(staff)" output
217 curuid=`$BIN_ID | cut -f 2 -d '=' | cut -f 1 -d '('`
218 if test "$curuid" -ne 0; then
219 errorprint "This script must be run with administrator privileges."
220 exit 1
221 fi
222}
223
224# get_sysinfo
225# cannot fail
226get_sysinfo()
227{
228 if test "$REMOTEINST" -eq 1 || test -z "$HOST_OS_MINORVERSION" || test -z "$HOST_OS_MAJORVERSION"; then
229 if test -f "$PKG_INSTALL_ROOT/etc/release"; then
230 HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | grep "Solaris 10"`
231 if test -n "$HOST_OS_MAJORVERSION"; then
232 HOST_OS_MAJORVERSION="5.10"
233 else
234 HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | egrep "snv_|oi_"`
235 if test -n "$HOST_OS_MAJORVERSION"; then
236 HOST_OS_MAJORVERSION="5.11"
237 fi
238 fi
239 if test "$HOST_OS_MAJORVERSION" != "5.10"; then
240 HOST_OS_MINORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | tr ' ' '\n' | egrep 'snv_|oi_' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9]//"`
241 else
242 HOST_OS_MINORVERSION=""
243 fi
244 else
245 HOST_OS_MAJORVERSION=""
246 HOST_OS_MINORVERSION=""
247 fi
248 fi
249}
250
251# check_zone()
252# !! failure is always fatal
253check_zone()
254{
255 currentzone=`zonename`
256 if test "$currentzone" != "global"; then
257 errorprint "This script must be run from the global zone."
258 exit 1
259 fi
260}
261
262# check_isa()
263# !! failure is always fatal
264check_isa()
265{
266 currentisa=`uname -i`
267 if test "$currentisa" = "i86xpv"; then
268 errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
269 exit 1
270 fi
271}
272
273# check_module_arch()
274# !! failure is always fatal
275check_module_arch()
276{
277 cputype=`isainfo -k`
278 if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
279 errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
280 exit 1
281 fi
282}
283
284# update_boot_archive()
285# cannot fail
286update_boot_archive()
287{
288 infoprint "Updating the boot archive..."
289 if test "$REMOTEINST" -eq 0; then
290 $BIN_BOOTADM update-archive > /dev/null
291 else
292 $BIN_BOOTADM update-archive -R "$PKG_INSTALL_ROOT" > /dev/null
293 fi
294 UPDATEBOOTARCHIVE=0
295}
296
297
298# module_added(modname)
299# returns 1 if added, 0 otherwise
300module_added()
301{
302 if test -z "$1"; then
303 errorprint "missing argument to module_added()"
304 exit 1
305 fi
306
307 # Add a space at end of module name to make sure we have a perfect match to avoid
308 # any substring matches: e.g "vboxusb" & "vboxusbmon"
309 loadentry=`cat "$PKG_INSTALL_ROOT/etc/name_to_major" | grep "$1 "`
310 if test -z "$loadentry"; then
311 return 1
312 fi
313 return 0
314}
315
316# module_loaded(modname)
317# returns 1 if loaded, 0 otherwise
318module_loaded()
319{
320 if test -z "$1"; then
321 errorprint "missing argument to module_loaded()"
322 exit 1
323 fi
324
325 modname=$1
326 # modinfo should now work properly since we prevent module autounloading.
327 loadentry=`$BIN_MODINFO | grep "$modname "`
328 if test -z "$loadentry"; then
329 return 1
330 fi
331 return 0
332}
333
334# add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
335# failure: depends on "fatal"
336add_driver()
337{
338 if test -z "$1" || test -z "$2"; then
339 errorprint "missing argument to add_driver()"
340 exit 1
341 fi
342
343 modname="$1"
344 moddesc="$2"
345 fatal="$3"
346 nullop="$4"
347 modperm="$5"
348
349 if test -n "$modperm"; then
350 if test "$nullop" = "$NULLOP"; then
351 $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
352 else
353 $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
354 fi
355 else
356 if test "$nullop" = "$NULLOP"; then
357 $BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
358 else
359 $BIN_ADDDRV $BASEDIR_OPT $modname
360 fi
361 fi
362
363 if test $? -ne 0; then
364 subprint "Adding: $moddesc module ...FAILED!"
365 if test "$fatal" = "$FATALOP"; then
366 exit 1
367 fi
368 return 1
369 elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
370 subprint "Added: $moddesc driver"
371 fi
372 return 0
373}
374
375# rem_driver(modname, moddesc, [fatal])
376# failure: depends on [fatal]
377rem_driver()
378{
379 if test -z "$1" || test -z "$2"; then
380 errorprint "missing argument to rem_driver()"
381 exit 1
382 fi
383
384 modname=$1
385 moddesc=$2
386 fatal=$3
387
388 module_added $modname
389 if test "$?" -eq 0; then
390 UPDATEBOOTARCHIVE=1
391 if test "$ISIPS" != "$IPSOP"; then
392 $BIN_REMDRV $BASEDIR_OPT $modname
393 else
394 $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
395 fi
396 # for remote installs, don't bother with return values of rem_drv
397 if test $? -eq 0; then
398 subprint "Removed: $moddesc module"
399 return 0
400 else
401 subprint "Removing: $moddesc ...FAILED!"
402 if test "$fatal" = "$FATALOP"; then
403 exit 1
404 fi
405 return 1
406 fi
407 fi
408}
409
410# unload_module(modname, moddesc, [fatal])
411# failure: fatal
412unload_module()
413{
414 if test -z "$1" || test -z "$2"; then
415 errorprint "missing argument to unload_module()"
416 exit 1
417 fi
418
419 # No-OP for non-root installs
420 if test "$REMOTEINST" -eq 1; then
421 return 0
422 fi
423
424 modname=$1
425 moddesc=$2
426 fatal=$3
427 modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
428 if test -n "$modid"; then
429 $BIN_MODUNLOAD -i $modid
430 if test $? -eq 0; then
431 subprint "Unloaded: $moddesc module"
432 else
433 subprint "Unloading: $moddesc module ...FAILED!"
434 if test "$fatal" = "$FATALOP"; then
435 exit 1
436 fi
437 return 1
438 fi
439 fi
440 return 0
441}
442
443# load_module(modname, moddesc, [fatal])
444# pass "drv/modname" or "misc/vbi" etc.
445# failure: fatal
446load_module()
447{
448 if test -z "$1" || test -z "$2"; then
449 errorprint "missing argument to load_module()"
450 exit 1
451 fi
452
453 # No-OP for non-root installs
454 if test "$REMOTEINST" -eq 1; then
455 return 0
456 fi
457
458 modname=$1
459 moddesc=$2
460 fatal=$3
461 $BIN_MODLOAD -p $modname
462 if test $? -eq 0; then
463 subprint "Loaded: $moddesc module"
464 return 0
465 else
466 subprint "Loading: $moddesc ...FAILED!"
467 if test "$fatal" = "$FATALOP"; then
468 exit 1
469 fi
470 return 1
471 fi
472}
473
474load_vboxflt()
475{
476 if test -f "$DIR_CONF/vboxflt.conf"; then
477 add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
478 load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
479 else
480 # For custom pkgs that optionally ship this module, let's not fail but just warn
481 warnprint "$DESC_VBOXFLT installation requested but not shipped in this package."
482 fi
483}
484
485load_vboxbow()
486{
487 if test -f "$DIR_CONF/vboxbow.conf"; then
488 add_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
489 load_module "drv/$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
490 else
491 # For custom pkgs that optionally ship this module, let's not fail but just warn
492 warnprint "$DESC_VBOXBOW installation requested but not shipped in this package."
493 fi
494}
495
496# install_drivers()
497# !! failure is always fatal
498install_drivers()
499{
500 if test -f "$DIR_CONF/vboxdrv.conf"; then
501 if test -n "_HARDENED_"; then
502 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys'"
503 else
504 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
505 fi
506 load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
507 else
508 errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
509 return 1
510 fi
511
512 # Add vboxdrv to devlink.tab
513 if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
514 sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
515 echo "type=ddi_pseudo;name=vboxdrv \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
516 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
517 else
518 errorprint "Missing $PKG_INSTALL_ROOT/etc/devlink.tab, aborting install"
519 return 1
520 fi
521
522 # Create the device link for non-remote installs
523 if test "$REMOTEINST" -eq 0; then
524 /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
525 if test $? -ne 0 || test ! -h "/dev/vboxdrv"; then
526 errorprint "Failed to create device link for $MOD_VBOXDRV."
527 exit 1
528 fi
529 fi
530
531 # Load VBoxNetAdp
532 if test -f "$DIR_CONF/vboxnet.conf"; then
533 add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
534 load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
535 fi
536
537 # If both vboxinst_vboxbow and vboxinst_vboxflt exist, bail.
538 if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt" && test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
539 errorprint "Force-install files '$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt' and '$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow' both exist."
540 errorprint "Cannot load $DESC_VBOXFLT and $DESC_VBOXBOW drivers at the same time."
541 return 1
542 fi
543
544 # If the force-install files exists, install blindly
545 if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt"; then
546 load_vboxflt
547 elif test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
548 infoprint "here"
549 load_vboxbow
550 else
551 # If host is S10 or S11 (< snv_159) or vboxbow isn't shipped, then load vboxflt
552 if test "$HOST_OS_MAJORVERSION" = "5.10" || test "$HOST_OS_MINORVERSION" -lt 159 || test ! -f "$DIR_CONF/vboxbow.conf"; then
553 load_vboxflt
554 else
555 # For S11 snv_159+ load vboxbow
556 load_vboxbow
557 fi
558 fi
559
560 # Load VBoxUSBMon, VBoxUSB
561 if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "5.10"; then
562 # For VirtualBox 3.1 the new USB code requires Nevada > 123
563 if test "$HOST_OS_MINORVERSION" -gt 123; then
564 add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
565 load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
566
567 # Add vboxusbmon to devlink.tab
568 sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
569 echo "type=ddi_pseudo;name=vboxusbmon \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
570 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
571
572 # Create the device link for non-remote installs
573 if test "$REMOTEINST" -eq 0; then
574 /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
575 if test $? -ne 0; then
576 errorprint "Failed to create device link for $MOD_VBOXUSBMON."
577 exit 1
578 fi
579 fi
580
581 # Add vboxusb if present
582 # This driver is special, we need it in the boot-archive but since there is no
583 # USB device to attach to now (it's done at runtime) it will fail to attach so
584 # redirect attaching failure output to /dev/null
585 if test -f "$DIR_CONF/vboxusb.conf"; then
586 add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
587 load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
588 fi
589 else
590 if test -n "$HOST_OS_MINORVERSION"; then
591 warnprint "Solaris 5.11 build 124 or higher required for USB support. Skipped installing USB support."
592 else
593 warnprint "Failed to determine Solaris 5.11 snv version. Skipped installing USB support."
594 fi
595 fi
596 fi
597
598 return $?
599}
600
601# remove_drivers([fatal])
602# failure: depends on [fatal]
603remove_drivers()
604{
605 fatal=$1
606
607 # Remove vboxdrv from devlink.tab
608 if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
609 devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxdrv`
610 if test -n "$devlinkfound"; then
611 sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
612 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
613 fi
614
615 # Remove vboxusbmon from devlink.tab
616 devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxusbmon`
617 if test -n "$devlinkfound"; then
618 sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
619 mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
620 fi
621 fi
622
623 unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
624 rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
625
626 unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
627 rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
628
629 unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
630 rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
631
632 unload_module "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
633 rem_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
634
635 unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
636 rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
637
638 unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
639 rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
640
641# No separate VBI since 3.1
642# unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
643
644 # remove devlinks
645 if test -h "$PKG_INSTALL_ROOT/dev/vboxdrv" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrv"; then
646 rm -f "$PKG_INSTALL_ROOT/dev/vboxdrv"
647 fi
648 if test -h "$PKG_INSTALL_ROOT/dev/vboxusbmon" || test -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"; then
649 rm -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"
650 fi
651
652 # unpatch nwam/dhcpagent fix
653 nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
654 nwambackupfile=$nwamfile.vbox
655 if test -f "$nwamfile"; then
656 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
657 mv -f $nwambackupfile $nwamfile
658 fi
659
660 # remove netmask configuration
661 if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
662 nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
663 else
664 nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
665 fi
666 nmaskbackupfile=$nmaskfile.vbox
667 if test -f "$nmaskfile"; then
668 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
669 mv -f $nmaskbackupfile $nmaskfile
670 fi
671
672 if test $UPDATEBOOTARCHIVE -eq 1; then
673 update_boot_archive
674 fi
675
676 return 0
677}
678
679# install_python_bindings(pythonbin)
680# remarks: changes pwd
681# failure: non fatal
682install_python_bindings()
683{
684 # The python binary might not be there, so just exit silently
685 if test -z "$1"; then
686 return 0
687 fi
688
689 if test -z "$2"; then
690 errorprint "missing argument to install_python_bindings"
691 exit 1
692 fi
693
694 pythonbin=$1
695 pythondesc=$2
696 if test -x "$pythonbin"; then
697 VBOX_INSTALL_PATH="$DIR_VBOXBASE"
698 export VBOX_INSTALL_PATH
699 cd $DIR_VBOXBASE/sdk/installer
700 $pythonbin ./vboxapisetup.py install > /dev/null
701 if test "$?" -eq 0; then
702 subprint "Installed: Bindings for $pythondesc"
703 fi
704 return 0
705 fi
706 return 1
707}
708
709# stop_process(processname)
710# failure: depends on [fatal]
711stop_process()
712{
713 if test -z "$1"; then
714 errorprint "missing argument to stop_process()"
715 exit 1
716 fi
717
718 procname=$1
719 procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
720 if test ! -z "$procpid" && test "$procpid" -ge 0; then
721 $BIN_PKILL "$procname"
722 sleep 2
723 procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
724 if test ! -z "$procpid" && test "$procpid" -ge 0; then
725 subprint "Terminating: $procname ...FAILED!"
726 if test "$fatal" = "$FATALOP"; then
727 exit 1
728 fi
729 else
730 subprint "Terminated: $procname"
731 fi
732 fi
733}
734
735
736# stop_service(servicename, shortFMRI-suitable for grep, full FMRI)
737# failure: non fatal
738stop_service()
739{
740 if test -z "$1" || test -z "$2" || test -z "$3"; then
741 errorprint "missing argument to stop_service()"
742 exit 1
743 fi
744 servicefound=`$BIN_SVCS -a | grep "$2" 2>/dev/null`
745 if test ! -z "$servicefound"; then
746 $BIN_SVCADM disable -s $3
747 # Don't delete the manifest, this is handled by the manifest class action
748 # $BIN_SVCCFG delete $3
749 if test "$?" -eq 0; then
750 subprint "Unloaded: $1"
751 else
752 subprint "Unloading: $1 ...ERROR(S)."
753 fi
754 fi
755}
756
757
758# cleanup_install([fatal])
759# failure: depends on [fatal]
760cleanup_install()
761{
762 fatal=$1
763
764 # No-Op for remote installs
765 if test "$REMOTEINST" -eq 1; then
766 return 0
767 fi
768
769 # stop the services
770 stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
771 stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
772 stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
773
774 # unplumb all vboxnet instances for non-remote installs
775 inst=0
776 while test $inst -ne $MOD_VBOXNET_INST; do
777 vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
778 if test "$?" -eq 0; then
779 $BIN_IFCONFIG vboxnet$inst unplumb
780 if test "$?" -ne 0; then
781 errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
782 if test "$fatal" = "$FATALOP"; then
783 exit 1
784 fi
785 fi
786 fi
787
788 # unplumb vboxnet0 ipv6
789 vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
790 if test "$?" -eq 0; then
791 $BIN_IFCONFIG vboxnet$inst inet6 unplumb
792 if test "$?" -ne 0; then
793 errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
794 if test "$fatal" = "$FATALOP"; then
795 exit 1
796 fi
797 fi
798 fi
799
800 inst=`expr $inst + 1`
801 done
802
803 # Stop our other daemons, non-fatal
804 stop_process VBoxSVC
805 stop_process VBoxNetDHCP
806}
807
808
809# postinstall()
810# !! failure is always fatal
811postinstall()
812{
813 infoprint "Detected Solaris $HOST_OS_MAJORVERSION Version $HOST_OS_MINORVERSION"
814 infoprint "Loading VirtualBox kernel modules..."
815 install_drivers
816
817 if test "$?" -eq 0; then
818 if test -f "$DIR_CONF/vboxnet.conf"; then
819 # nwam/dhcpagent fix
820 nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
821 nwambackupfile=$nwamfile.vbox
822 if test -f "$nwamfile"; then
823 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
824
825 # add all vboxnet instances as static to nwam
826 inst=0
827 networkn=56
828 while test $inst -ne 1; do
829 echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
830 inst=`expr $inst + 1`
831 networkn=`expr $networkn + 1`
832 done
833 mv -f $nwambackupfile $nwamfile
834 fi
835
836 # plumb and configure vboxnet0 for non-remote installs
837 if test "$REMOTEINST" -eq 0; then
838 $BIN_IFCONFIG vboxnet0 plumb
839 $BIN_IFCONFIG vboxnet0 up
840 if test "$?" -eq 0; then
841 $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
842
843 # /etc/netmasks is a symlink, older installers replaced this with
844 # a copy of the actual file, repair that behaviour here.
845 recreatelink=0
846 if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
847 nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
848 else
849 nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
850 recreatelink=1
851 fi
852
853 # add the netmask to stay persistent across host reboots
854 nmaskbackupfile=$nmaskfile.vbox
855 if test -f $nmaskfile; then
856 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
857
858 if test $recreatelink -eq 1; then
859 # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
860 anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
861 if test ! -z $anydiff; then
862 # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
863 recreatelink=2
864 fi
865 fi
866
867 echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
868 inst=0
869 networkn=56
870 while test $inst -ne 1; do
871 echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
872 inst=`expr $inst + 1`
873 networkn=`expr $networkn + 1`
874 done
875 echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
876 mv -f $nmaskbackupfile $nmaskfile
877
878 # Recreate /etc/netmasks as a link if necessary
879 if test $recreatelink -eq 1; then
880 cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
881 ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
882 elif test $recreatelink -eq 2; then
883 warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
884 warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
885 warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
886 warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
887 warnprint "symlink to /etc/inet/netmasks. Please resolve this manually."
888 fi
889 fi
890 else
891 # Should this be fatal?
892 warnprint "Failed to bring up vboxnet0!!"
893 fi
894 fi
895 fi
896
897 if test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml" || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
898 infoprint "Configuring services..."
899 if test "$REMOTEINST" -eq 1; then
900 subprint "Skipped for targetted installs."
901 else
902 # Enable Zone access service for non-remote installs, other services (Webservice) are delivered disabled by the manifest class action
903 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" | grep "disabled" 2>/dev/null`
904 if test ! -z "$servicefound"; then
905 /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
906 if test "$?" -eq 0; then
907 subprint "Loaded: Zone access service"
908 else
909 subprint "Loading Zone access service ...FAILED."
910 fi
911 fi
912 fi
913 fi
914
915 # Update mime and desktop databases to get the right menu entries
916 # and icons. There is still some delay until the GUI picks it up,
917 # but that cannot be helped.
918 if test -d "$PKG_INSTALL_ROOT/usr/share/icons"; then
919 infoprint "Installing MIME types and icons..."
920 if test "$REMOTEINST" -eq 0; then
921 /usr/bin/update-mime-database /usr/share/mime >/dev/null 2>&1
922 /usr/bin/update-desktop-database -q 2>/dev/null
923 else
924 subprint "Skipped for targetted installs."
925 fi
926 fi
927
928 # Install python bindings for non-remote installs
929 if test "$REMOTEINST" -eq 0; then
930 if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
931 PYTHONBIN=`which python 2> /dev/null`
932 if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
933 infoprint "Installing Python bindings..."
934
935 INSTALLEDIT=1
936 PYTHONBIN=`which python2.4 2>/dev/null`
937 install_python_bindings "$PYTHONBIN" "Python 2.4"
938 if test "$?" -eq 0; then
939 INSTALLEDIT=0
940 fi
941 PYTHONBIN=`which python2.5 2>/dev/null`
942 install_python_bindings "$PYTHONBIN" "Python 2.5"
943 if test "$?" -eq 0; then
944 INSTALLEDIT=0
945 fi
946 PYTHONBIN=`which python2.6 2>/dev/null`
947 install_python_bindings "$PYTHONBIN" "Python 2.6"
948 if test "$?" -eq 0; then
949 INSTALLEDIT=0
950 fi
951
952 # remove files installed by Python build
953 rm -rf $DIR_VBOXBASE/sdk/installer/build
954
955 if test "$INSTALLEDIT" -ne 0; then
956 warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
957 warnprint "Skipped installing the Python bindings."
958 fi
959 else
960 warnprint "Python not found, skipped installed Python bindings."
961 fi
962 fi
963 else
964 warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
965 fi
966
967 update_boot_archive
968
969 return 0
970 else
971 errorprint "Failed to install drivers"
972 exit 666
973 fi
974 return 1
975}
976
977# preremove([fatal])
978# failure: depends on [fatal]
979preremove()
980{
981 fatal=$1
982
983 cleanup_install "$fatal"
984
985 remove_drivers "$fatal"
986 if test "$?" -eq 0; then
987 return 0;
988 fi
989 return 1
990}
991
992
993
994# And it begins...
995find_bins
996check_root
997check_isa
998check_zone
999get_sysinfo
1000
1001if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
1002 BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
1003 REMOTEINST=1
1004fi
1005
1006# Get command line options
1007while test $# -gt 0;
1008do
1009 case "$1" in
1010 --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
1011 drvop="$1"
1012 ;;
1013 --fatal)
1014 fatal="$FATALOP"
1015 ;;
1016 --silent)
1017 ISSILENT="$SILENTOP"
1018 ;;
1019 --ips)
1020 ISIPS="$IPSOP"
1021 ;;
1022 --altkerndir)
1023 # Use alternate kernel driver config folder (dev only)
1024 DIR_CONF="/usr/kernel/drv"
1025 ;;
1026 --help)
1027 printusage
1028 exit 1
1029 ;;
1030 *)
1031 break
1032 ;;
1033 esac
1034 shift
1035done
1036
1037case "$drvop" in
1038--postinstall)
1039 check_module_arch
1040 postinstall
1041 ;;
1042--preremove)
1043 preremove "$fatal"
1044 ;;
1045--installdrivers)
1046 check_module_arch
1047 install_drivers
1048 ;;
1049--removedrivers)
1050 remove_drivers "$fatal"
1051 ;;
1052--setupdrivers)
1053 remove_drivers "$fatal"
1054 infoprint "Installing VirtualBox drivers:"
1055 install_drivers
1056 ;;
1057*)
1058 printusage
1059 exit 1
1060esac
1061
1062exit "$?"
1063
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