VirtualBox

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

Last change on this file since 31421 was 31421, checked in by vboxsync, 14 years ago

Solaris/Installer: bin path fixes.

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