VirtualBox

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

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

Solaris/Installer: Install USB on OpenIndiana based installs.

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