VirtualBox

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

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

Solaris/Installer: Paranoia.

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