VirtualBox

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

Last change on this file since 31425 was 31425, checked in by vboxsync, 15 years ago

Solaris/Installer: comment.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 25.4 KB
Line 
1#!/bin/sh
2# $Id: vboxconfig.sh 31425 2010-08-05 19:50:43Z vboxsync $
3
4# Sun VirtualBox
5# VirtualBox Configuration Script, Solaris host.
6#
7# Copyright (C) 2009 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
21# S10 or OpenSoalris
22HOST_OS_MAJORVERSION=`uname -r`
23# Which OpenSolaris version (snv_xxx)?
24HOST_OS_MINORVERSION=`uname -v | grep 'snv' | sed -e "s/snv_//" -e "s/[^0-9]//"`
25
26DIR_VBOXBASE=${BASEDIR}/opt/VirtualBox
27DIR_CONF="${BASEDIR}/platform/i86pc/kernel/drv"
28DIR_MOD_32="${BASEDIR}/platform/i86pc/kernel/drv"
29DIR_MOD_64=$DIR_MOD_32/amd64
30
31# Default paths, these will be overridden by 'which' if they don't exist
32BIN_ADDDRV=/usr/sbin/add_drv
33BIN_REMDRV=/usr/sbin/rem_drv
34BIN_MODLOAD=/usr/sbin/modload
35BIN_MODUNLOAD=/usr/sbin/modunload
36BIN_MODINFO=/usr/sbin/modinfo
37BIN_DEVFSADM=/usr/sbin/devfsadm
38BIN_BOOTADM=/sbin/bootadm
39BIN_SVCADM=/usr/sbin/svcadm
40BIN_SVCCFG=/usr/sbin/svccfg
41BIN_IFCONFIG=/sbin/ifconfig
42BIN_SVCS=/usr/bin/svcs
43BIN_ID=/usr/bin/id
44
45# "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
46MOD_VBOXDRV=vboxdrv
47DESC_VBOXDRV="Host"
48
49MOD_VBOXNET=vboxnet
50DESC_VBOXNET="NetAdapter"
51MOD_VBOXNET_INST=32
52
53MOD_VBOXFLT=vboxflt
54DESC_VBOXFLT="NetFilter"
55
56# No Separate VBI since (3.1)
57#MOD_VBI=vbi
58#DESC_VBI="Kernel Interface"
59
60MOD_VBOXUSBMON=vboxusbmon
61DESC_VBOXUSBMON="USBMonitor"
62
63MOD_VBOXUSB=vboxusb
64DESC_VBOXUSB="USB"
65
66REMOTEINST=0
67FATALOP=fatal
68NULLOP=nulloutput
69SILENTOP=silent
70IPSOP=ips
71ISSILENT=
72ISIPS=
73
74infoprint()
75{
76 if test "$ISSILENT" != "$SILENTOP"; then
77 echo 1>&2 "$1"
78 fi
79}
80
81subprint()
82{
83 if test "$ISSILENT" != "$SILENTOP"; then
84 echo 1>&2 " - $1"
85 fi
86}
87
88warnprint()
89{
90 if test "$ISSILENT" != "$SILENTOP"; then
91 echo 1>&2 " * Warning!! $1"
92 fi
93}
94
95errorprint()
96{
97 echo 1>&2 "## $1"
98}
99
100
101# find_bin_path()
102# !! failure is always fatal
103find_bin_path()
104{
105 binfilename=`basename $1`
106 binfilepath=`which $binfilename 2> /dev/null`
107 if test -x "$binfilepath"; then
108 echo "$binfilepath"
109 return 0
110 else
111 errorprint "$1 missing or is not an executable"
112 exit 1
113 fi
114}
115
116# find_bins()
117# !! failure is always fatal
118find_bins()
119{
120 # Search only for binaries that might be in different locations
121 if test ! -x "$BIN_ID"; then
122 BIN_ID=`find_bin_path "$BIN_ID"`
123 fi
124
125 if test ! -x "$BIN_ADDDRV"; then
126 BIN_ADDDRV=`find_bin_path "$BIN_ADDDRV"`
127 fi
128
129 if test ! -x "$BIN_REMDRV"; then
130 BIN_REMDRV=`find_bin_path "$BIN_REMDRV"`
131 fi
132
133 if test ! -x "$BIN_MODLOAD"; then
134 BIN_MODLOAD=`check_bin_path "$BIN_MODLOAD"`
135 fi
136
137 if test ! -x "$BIN_MODUNLOAD"; then
138 BIN_MODUNLOAD=`find_bin_path "$BIN_MODUNLOAD"`
139 fi
140
141 if test ! -x "$BIN_MODINFO"; then
142 BIN_MODINFO=`find_bin_path "$BIN_MODINFO"`
143 fi
144
145 if test ! -x "$BIN_DEVFSADM"; then
146 BIN_DEVFSADM=`find_bin_path "$BIN_DEVFSADM"`
147 fi
148
149 if test ! -x "$BIN_BOOTADM"; then
150 BIN_BOOTADM=`find_bin_path "$BIN_BOOTADM"`
151 fi
152
153 if test ! -x "$BIN_BOOTADM"; then
154 BIN_BOOTADM=`find_bin_path "$BIN_BOOTADM"`
155 fi
156
157 if test ! -x "$BIN_SVCCFG"; then
158 BIN_SVCCFG=`find_bin_path "$BIN_SVCCFG"`
159 fi
160
161 if test ! -x "$BIN_SVCS"; then
162 BIN_SVCS=`find_bin_path "$BIN_SVCS"`
163 fi
164
165 if test ! -x "$BIN_IFCONFIG"; then
166 BIN_IFCONFIG=`find_bin_path "$BIN_IFCONFIG"`
167 fi
168}
169
170# check_root()
171# !! failure is always fatal
172check_root()
173{
174 # Don't use "-u" option as some id binaries don't support it, instead
175 # rely on "uid=101(username) gid=10(groupname) groups=10(staff)" output
176 curuid=`$BIN_ID | cut -f 2 -d '=' | cut -f 1 -d '('`
177 if test "$curuid" -ne 0; then
178 errorprint "This script must be run with administrator privileges."
179 exit 1
180 fi
181}
182
183# get_sysinfo
184# cannot fail
185get_sysinfo()
186{
187 if test "$REMOTEINST" -eq 1 || test -z "$HOST_OS_MINORVERSION" || test -z "$HOST_OS_MAJORVERSION"; then
188 if test -f "${BASEDIR}/etc/release"; then
189 HOST_OS_MAJORVERSION=`cat ${BASEDIR}/etc/release | grep "Solaris 10"`
190 if test -n "$HOST_OS_MAJORVERSION"; then
191 HOST_OS_MAJORVERSION="5.10"
192 else
193 HOST_OS_MAJORVERSION=`cat ${BASEDIR}/etc/release | grep "snv_"`
194 if test -n "$HOST_OS_MAJORVERSION"; then
195 HOST_OS_MAJORVERSION="5.11"
196 fi
197 fi
198 if test "$HOST_OS_MAJORVERSION" != "5.10"; then
199 HOST_OS_MINORVERSION=`cat ${BASEDIR}/etc/release | tr ' ' '\n' | grep 'snv_' | sed -e "s/snv_//" -e "s/[^0-9]//"`
200 else
201 HOST_OS_MINORVERSION=""
202 fi
203 else
204 HOST_OS_MAJORVERSION=""
205 HOST_OS_MINORVERSION=""
206 fi
207 fi
208}
209
210# check_zone()
211# !! failure is always fatal
212check_zone()
213{
214 currentzone=`zonename`
215 if test "$currentzone" != "global"; then
216 errorprint "This script must be run from the global zone."
217 exit 1
218 fi
219}
220
221# check_isa()
222# !! failure is always fatal
223check_isa()
224{
225 currentisa=`uname -i`
226 if test "$currentisa" = "i86xpv"; then
227 errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
228 exit 1
229 fi
230}
231
232# check_module_arch()
233# !! failure is always fatal
234check_module_arch()
235{
236 cputype=`isainfo -k`
237 if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
238 errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
239 exit 1
240 fi
241}
242
243# module_added(modname)
244# returns 1 if added, 0 otherwise
245module_added()
246{
247 if test -z "$1"; then
248 errorprint "missing argument to module_added()"
249 exit 1
250 fi
251
252 # Add a space at end of module name to make sure we have a perfect match to avoid
253 # any substring matches: e.g "vboxusb" & "vbo $BASEDIR_OPT xusbmon"
254 loadentry=`cat ${BASEDIR}/etc/name_to_major | grep "$1 "`
255 if test -z "$loadentry"; then
256 return 1
257 fi
258 return 0
259}
260
261# module_loaded(modname)
262# returns 1 if loaded, 0 otherwise
263module_loaded()
264{
265 if test -z "$1"; then
266 errorprint "missing argument to module_loaded()"
267 exit 1
268 fi
269
270 modname=$1
271 # modinfo should now work properly since we prevent module autounloading.
272 loadentry=`$BIN_MODINFO | grep "$modname "`
273 if test -z "$loadentry"; then
274 return 1
275 fi
276 return 0
277}
278
279# add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
280# failure: depends on "fatal"
281add_driver()
282{
283 if test -z "$1" || test -z "$2"; then
284 errorprint "missing argument to add_driver()"
285 exit 1
286 fi
287
288 modname="$1"
289 moddesc="$2"
290 fatal="$3"
291 nullop="$4"
292 modperm="$5"
293
294 if test -n "$modperm"; then
295 if test "$nullop" = "$NULLOP"; then
296 $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
297 else
298 $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
299 fi
300 else
301 if test "$nullop" = "$NULLOP"; then
302 $BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
303 else
304 $BIN_ADDDRV $BASEDIR_OPT $modname
305 fi
306 fi
307
308 if test $? -ne 0; then
309 subprint "Adding: $moddesc module ...FAILED!"
310 if test "$fatal" = "$FATALOP"; then
311 exit 1
312 fi
313 return 1
314 elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
315 subprint "Added: $moddesc driver"
316 fi
317 return 0
318}
319
320# rem_driver(modname, moddesc, [fatal])
321# failure: depends on [fatal]
322rem_driver()
323{
324 if test -z "$1" || test -z "$2"; then
325 errorprint "missing argument to rem_driver()"
326 exit 1
327 fi
328
329 modname=$1
330 moddesc=$2
331 fatal=$3
332
333 module_added $modname
334 if test "$?" -eq 0; then
335 if test "$ISIPS" != "$IPSOP"; then
336 $BIN_REMDRV $BASEDIR_OPT $modname
337 else
338 $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
339 fi
340 # for remote installs, don't bother with return values of rem_drv
341 if test $? -eq 0; then
342 subprint "Removed: $moddesc module"
343 return 0
344 else
345 subprint "Removing: $moddesc ...FAILED!"
346 if test "$fatal" = "$FATALOP"; then
347 exit 1
348 fi
349 return 1
350 fi
351 fi
352}
353
354# unload_module(modname, moddesc, [fatal])
355# failure: fatal
356unload_module()
357{
358 if test -z "$1" || test -z "$2"; then
359 errorprint "missing argument to unload_module()"
360 exit 1
361 fi
362
363 # No-OP for non-root installs
364 if test "$REMOTEINST" -eq 1; then
365 return 0
366 fi
367
368 modname=$1
369 moddesc=$2
370 fatal=$3
371 modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
372 if test -n "$modid"; then
373 $BIN_MODUNLOAD -i $modid
374 if test $? -eq 0; then
375 subprint "Unloaded: $moddesc module"
376 else
377 subprint "Unloading: $moddesc module ...FAILED!"
378 if test "$fatal" = "$FATALOP"; then
379 exit 1
380 fi
381 return 1
382 fi
383 fi
384 return 0
385}
386
387# load_module(modname, moddesc, [fatal])
388# pass "drv/modname" or "misc/vbi" etc.
389# failure: fatal
390load_module()
391{
392 if test -z "$1" || test -z "$2"; then
393 errorprint "missing argument to load_module()"
394 exit 1
395 fi
396
397 # No-OP for non-root installs
398 if test "$REMOTEINST" -eq 1; then
399 return 0
400 fi
401
402 modname=$1
403 moddesc=$2
404 fatal=$3
405 $BIN_MODLOAD -p $modname
406 if test $? -eq 0; then
407 subprint "Loaded: $moddesc module"
408 return 0
409 else
410 subprint "Loading: $moddesc ...FAILED!"
411 if test "$fatal" = "$FATALOP"; then
412 exit 1
413 fi
414 return 1
415 fi
416}
417
418# install_drivers()
419# !! failure is always fatal
420install_drivers()
421{
422 if test -f "$DIR_CONF/vboxdrv.conf"; then
423 if test -n "_HARDENED_"; then
424 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys'"
425 else
426 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
427 fi
428 load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
429 else
430 errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
431 return 1
432 fi
433
434 # Add vboxdrv to devlink.tab
435 if test -f "${BASEDIR}/etc/devlink.tab"; then
436 sed -e '/name=vboxdrv/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
437 echo "type=ddi_pseudo;name=vboxdrv \D" >> ${BASEDIR}/etc/devlink.vbox
438 mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
439 else
440 errorprint "Missing ${BASEDIR}/etc/devlink.tab, aborting install"
441 return 1
442 fi
443
444 # Create the device link for non-remote installs
445 if test "$REMOTEINST" -eq 0; then
446 /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
447 if test $? -ne 0 || test ! -h "/dev/vboxdrv"; then
448 errorprint "Failed to create device link for $MOD_VBOXDRV."
449 exit 1
450 fi
451 fi
452
453 # Load VBoxNetAdp
454 if test -f "$DIR_CONF/vboxnet.conf"; then
455 add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
456 load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
457 fi
458
459 # Load VBoxNetFlt
460 if test -f "$DIR_CONF/vboxflt.conf"; then
461 add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
462 load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
463 fi
464
465 # Load VBoxUSBMon, VBoxUSB
466 if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "5.10"; then
467 # For VirtualBox 3.1 the new USB code requires Nevada > 123
468 if test "$HOST_OS_MINORVERSION" -gt 123; then
469 add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
470 load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
471
472 # Add vboxusbmon to devlink.tab
473 sed -e '/name=vboxusbmon/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
474 echo "type=ddi_pseudo;name=vboxusbmon \D" >> ${BASEDIR}/etc/devlink.vbox
475 mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
476
477 # Create the device link for non-remote installs
478 if test "$REMOTEINST" -eq 0; then
479 /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
480 if test $? -ne 0; then
481 errorprint "Failed to create device link for $MOD_VBOXUSBMON."
482 exit 1
483 fi
484 fi
485
486 # Add vboxusb if present
487 # This driver is special, we need it in the boot-archive but since there is no
488 # USB device to attach to now (it's done at runtime) it will fail to attach so
489 # redirect attaching failure output to /dev/null
490 if test -f "$DIR_CONF/vboxusb.conf"; then
491 add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
492 load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
493 fi
494 else
495 if test -n "$HOST_OS_MINORVERSION"; then
496 warnprint "Solaris 5.11 snv_124 or higher required for USB support. Skipped installing USB support."
497 else
498 warnprint "Failed to determine Solaris 5.11 snv version. Skipped installing USB support."
499 fi
500 fi
501 fi
502
503 return $?
504}
505
506# remove_all([fatal])
507# failure: depends on [fatal]
508remove_drivers()
509{
510 fatal=$1
511
512 # Remove vboxdrv from devlink.tab
513 if test -f ${BASEDIR}/etc/devlink.tab; then
514 devlinkfound=`cat ${BASEDIR}/etc/devlink.tab | grep vboxdrv`
515 if test -n "$devlinkfound"; then
516 sed -e '/name=vboxdrv/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
517 mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
518 fi
519
520 # Remove vboxusbmon from devlink.tab
521 devlinkfound=`cat ${BASEDIR}/etc/devlink.tab | grep vboxusbmon`
522 if test -n "$devlinkfound"; then
523 sed -e '/name=vboxusbmon/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
524 mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
525 fi
526 fi
527
528 unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
529 rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
530
531 unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
532 rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
533
534 unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
535 rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
536
537 unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
538 rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
539
540 unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
541 rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
542
543# No separate VBI since 3.1
544# unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
545
546 # remove devlinks
547 if test -h "${BASEDIR}/dev/vboxdrv" || test -f "${BASEDIR}/dev/vboxdrv"; then
548 rm -f ${BASEDIR}/dev/vboxdrv
549 fi
550 if test -h "${BASEDIR}/dev/vboxusbmon" || test -f "${BASEDIR}/dev/vboxusbmon"; then
551 rm -f ${BASEDIR}/dev/vboxusbmon
552 fi
553
554 # unpatch nwam/dhcpagent fix
555 nwamfile=${BASEDIR}/etc/nwam/llp
556 nwambackupfile=$nwamfile.vbox
557 if test -f "$nwamfile"; then
558 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
559 mv -f $nwambackupfile $nwamfile
560 fi
561
562 # remove netmask configuration
563 nmaskfile=${BASEDIR}/etc/netmasks
564 nmaskbackupfile=$nmaskfile.vbox
565 if test -f "$nmaskfile"; then
566 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
567 mv -f $nmaskbackupfile $nmaskfile
568 fi
569
570 return 0
571}
572
573# install_python_bindings(pythonbin)
574# remarks: changes pwd
575# failure: non fatal
576install_python_bindings()
577{
578 # The python binary might not be there, so just exit silently
579 if test -z "$1"; then
580 return 0
581 fi
582
583 if test -z "$2"; then
584 errorprint "missing argument to install_python_bindings"
585 exit 1
586 fi
587
588 pythonbin=$1
589 pythondesc=$2
590 if test -x "$pythonbin"; then
591 VBOX_INSTALL_PATH="$DIR_VBOXBASE"
592 export VBOX_INSTALL_PATH
593 cd $DIR_VBOXBASE/sdk/installer
594 $pythonbin ./vboxapisetup.py install > /dev/null
595 if test "$?" -eq 0; then
596 subprint "Installed: Bindings for $pythondesc"
597 fi
598 return 0
599 fi
600 return 1
601}
602
603
604# cleanup_install([fatal])
605# failure: depends on [fatal]
606cleanup_install()
607{
608 fatal=$1
609
610 # No-Op for remote installs
611 if test "$REMOTEINST" -eq 1; then
612 return 0
613 fi
614
615 # stop webservice
616 servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
617 if test ! -z "$servicefound"; then
618 $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
619 # Don't delete the manifest, this is handled by the manifest class action
620 # $BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
621 if test "$?" -eq 0; then
622 subprint "Unloaded: Web service"
623 else
624 subprint "Unloading: Web service ...ERROR(S)."
625 fi
626 fi
627
628 # stop zoneaccess service
629 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
630 if test ! -z "$servicefound"; then
631 $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
632 # Don't delete the manifest, this is handled by the manifest class action
633 # $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
634 if test "$?" -eq 0; then
635 subprint "Unloaded: Zone access service"
636 else
637 subprint "Unloading: Zone access service ...ERROR(S)."
638 fi
639 fi
640
641 # unplumb all vboxnet instances for non-remote installs
642 inst=0
643 while test $inst -ne $MOD_VBOXNET_INST; do
644 vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
645 if test "$?" -eq 0; then
646 $BIN_IFCONFIG vboxnet$inst unplumb
647 if test "$?" -ne 0; then
648 errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
649 if test "$fatal" = "$FATALOP"; then
650 exit 1
651 fi
652 fi
653 fi
654
655 # unplumb vboxnet0 ipv6
656 vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
657 if test "$?" -eq 0; then
658 $BIN_IFCONFIG vboxnet$inst inet6 unplumb
659 if test "$?" -ne 0; then
660 errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
661 if test "$fatal" = "$FATALOP"; then
662 exit 1
663 fi
664 fi
665 fi
666
667 inst=`expr $inst + 1`
668 done
669}
670
671
672# postinstall()
673# !! failure is always fatal
674postinstall()
675{
676 infoprint "Loading VirtualBox kernel modules..."
677 install_drivers
678
679 if test "$?" -eq 0; then
680 if test -f "$DIR_CONF/vboxnet.conf"; then
681 # nwam/dhcpagent fix
682 nwamfile=${BASEDIR}/etc/nwam/llp
683 nwambackupfile=$nwamfile.vbox
684 if test -f "$nwamfile"; then
685 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
686
687 # add all vboxnet instances as static to nwam
688 inst=0
689 networkn=56
690 while test $inst -ne 1; do
691 echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
692 inst=`expr $inst + 1`
693 networkn=`expr $networkn + 1`
694 done
695 mv -f $nwambackupfile $nwamfile
696 fi
697
698 # plumb and configure vboxnet0 for non-remote installs
699 if test "$REMOTEINST" -eq 0; then
700 $BIN_IFCONFIG vboxnet0 plumb up
701 if test "$?" -eq 0; then
702 $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
703
704 # add the netmask to stay persistent across host reboots
705 nmaskfile=${BASEDIR}/etc/netmasks
706 nmaskbackupfile=$nmaskfile.vbox
707 if test -f $nmaskfile; then
708 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
709 echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
710 inst=0
711 networkn=56
712 while test $inst -ne 1; do
713 echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
714 inst=`expr $inst + 1`
715 networkn=`expr $networkn + 1`
716 done
717 echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
718 mv -f $nmaskbackupfile $nmaskfile
719 fi
720 else
721 # Should this be fatal?
722 warnprint "Failed to bring up vboxnet0!!"
723 fi
724 fi
725 fi
726
727 if test -f ${BASEDIR}/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f ${BASEDIR}/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
728 infoprint "Configuring services..."
729 if test "$REMOTEINST" -eq 1; then
730 subprint "Skipped for targetted installs."
731 fi
732 fi
733
734 # Enable Zone access service for non-remote installs, other services (Webservice) are delivered disabled by the manifest class action
735 if test "$REMOTEINST" -eq 0; then
736 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" | grep "disabled" 2>/dev/null`
737 if test ! -z "$servicefound"; then
738 /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
739 if test "$?" -eq 0; then
740 subprint "Loaded: Zone access service"
741 else
742 subprint "Loading Zone access service ...FAILED."
743 fi
744 fi
745 fi
746
747 # Install python bindings for non-remote installs
748 if test "$REMOTEINST" -eq 0; then
749 if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
750 PYTHONBIN=`which python 2> /dev/null`
751 if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
752 infoprint "Installing Python bindings..."
753
754 INSTALLEDIT=1
755 PYTHONBIN=`which python2.4 2>/dev/null`
756 install_python_bindings "$PYTHONBIN" "Python 2.4"
757 if test "$?" -eq 0; then
758 INSTALLEDIT=0
759 fi
760 PYTHONBIN=`which python2.5 2>/dev/null`
761 install_python_bindings "$PYTHONBIN" "Python 2.5"
762 if test "$?" -eq 0; then
763 INSTALLEDIT=0
764 fi
765 PYTHONBIN=`which python2.6 2>/dev/null`
766 install_python_bindings "$PYTHONBIN" "Python 2.6"
767 if test "$?" -eq 0; then
768 INSTALLEDIT=0
769 fi
770
771 # remove files installed by Python build
772 rm -rf $DIR_VBOXBASE/sdk/installer/build
773
774 if test "$INSTALLEDIT" -ne 0; then
775 warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
776 warnprint "Skipped installing the Python bindings."
777 fi
778 else
779 warnprint "Python not found, skipped installed Python bindings."
780 fi
781 fi
782 else
783 warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
784 fi
785
786 # Update boot archive
787 infoprint "Updating the boot archive..."
788 if test "$REMOTEINST" -eq 0; then
789 $BIN_BOOTADM update-archive > /dev/null
790 else
791 $BIN_BOOTADM update-archive -R ${BASEDIR} > /dev/null
792 fi
793
794 return 0
795 else
796 errorprint "Failed to install drivers"
797 exit 666
798 fi
799 return 1
800}
801
802# preremove([fatal])
803# failure: depends on [fatal]
804preremove()
805{
806 fatal=$1
807
808 cleanup_install "$fatal"
809
810 remove_drivers "$fatal"
811 if test "$?" -eq 0; then
812 return 0;
813 fi
814 return 1
815}
816
817
818
819# And it begins...
820find_bins
821check_root
822check_isa
823check_zone
824get_sysinfo
825
826if test "x${BASEDIR:=/}" != "x/"; then
827 BASEDIR_OPT="-b ${BASEDIR}"
828 REMOTEINST=1
829fi
830
831# Get command line options
832while test $# -gt 0;
833do
834 case "$1" in
835 --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
836 drvop="$1"
837 ;;
838 --fatal)
839 fatal="$FATALOP"
840 ;;
841 --silent)
842 ISSILENT="$SILENTOP"
843 ;;
844 --ips)
845 ISIPS="$IPSOP"
846 ;;
847 --altkerndir)
848 # Use alternate kernel driver config folder (dev only)
849 DIR_CONF="/usr/kernel/drv"
850 ;;
851 *)
852 break
853 ;;
854 esac
855 shift
856done
857
858case "$drvop" in
859--postinstall)
860 check_module_arch
861 postinstall
862 ;;
863--preremove)
864 preremove "$fatal"
865 ;;
866--installdrivers)
867 check_module_arch
868 install_drivers
869 ;;
870--removedrivers)
871 remove_drivers "$fatal"
872 ;;
873--setupdrivers)
874 remove_drivers "$fatal"
875 install_drivers
876 ;;
877*)
878 errorprint "Invalid operation $drvop"
879 exit 1
880esac
881
882exit "$?"
883
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