VirtualBox

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

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

Installer/solaris: install VBoxBalloonCtrl.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 29.0 KB
Line 
1#!/bin/sh
2# $Id: vboxconfig.sh 36687 2011-04-15 16:44:36Z 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 balloonctrl
689 servicefound=`$BIN_SVCS -a | grep "virtualbox/balloonctrl" 2>/dev/null`
690 if test ! -z "$servicefound"; then
691 $BIN_SVCADM disable -s svc:/application/virtualbox/balloonctrl:default
692 # Don't delete the manifest, this is handled by the manifest class action
693 # $BIN_SVCCFG delete svc:/application/virtualbox/balloonctrl:default
694 if test "$?" -eq 0; then
695 subprint "Unloaded: Balloon control service"
696 else
697 subprint "Unloading: Balloon control service ...ERROR(S)."
698 fi
699 fi
700
701
702 # stop zoneaccess service
703 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
704 if test ! -z "$servicefound"; then
705 $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess:default
706 # Don't delete the manifest, this is handled by the manifest class action
707 # $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
708 if test "$?" -eq 0; then
709 subprint "Unloaded: Zone access service"
710 else
711 subprint "Unloading: Zone access service ...ERROR(S)."
712 fi
713 fi
714
715 # unplumb all vboxnet instances for non-remote installs
716 inst=0
717 while test $inst -ne $MOD_VBOXNET_INST; do
718 vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
719 if test "$?" -eq 0; then
720 $BIN_IFCONFIG vboxnet$inst unplumb
721 if test "$?" -ne 0; then
722 errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
723 if test "$fatal" = "$FATALOP"; then
724 exit 1
725 fi
726 fi
727 fi
728
729 # unplumb vboxnet0 ipv6
730 vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
731 if test "$?" -eq 0; then
732 $BIN_IFCONFIG vboxnet$inst inet6 unplumb
733 if test "$?" -ne 0; then
734 errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
735 if test "$fatal" = "$FATALOP"; then
736 exit 1
737 fi
738 fi
739 fi
740
741 inst=`expr $inst + 1`
742 done
743
744 # Stop our other daemons, non-fatal
745 stop_process VBoxSVC
746 stop_process VBoxNetDHCP
747}
748
749
750# postinstall()
751# !! failure is always fatal
752postinstall()
753{
754 infoprint "Loading VirtualBox kernel modules..."
755 install_drivers
756
757 if test "$?" -eq 0; then
758 if test -f "$DIR_CONF/vboxnet.conf"; then
759 # nwam/dhcpagent fix
760 nwamfile=$PKG_INSTALL_ROOT/etc/nwam/llp
761 nwambackupfile=$nwamfile.vbox
762 if test -f "$nwamfile"; then
763 sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
764
765 # add all vboxnet instances as static to nwam
766 inst=0
767 networkn=56
768 while test $inst -ne 1; do
769 echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
770 inst=`expr $inst + 1`
771 networkn=`expr $networkn + 1`
772 done
773 mv -f $nwambackupfile $nwamfile
774 fi
775
776 # plumb and configure vboxnet0 for non-remote installs
777 if test "$REMOTEINST" -eq 0; then
778 $BIN_IFCONFIG vboxnet0 plumb up
779 if test "$?" -eq 0; then
780 $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
781
782 # add the netmask to stay persistent across host reboots
783 nmaskfile=$PKG_INSTALL_ROOT/etc/netmasks
784 nmaskbackupfile=$nmaskfile.vbox
785 if test -f $nmaskfile; then
786 sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
787 echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
788 inst=0
789 networkn=56
790 while test $inst -ne 1; do
791 echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
792 inst=`expr $inst + 1`
793 networkn=`expr $networkn + 1`
794 done
795 echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
796 mv -f $nmaskbackupfile $nmaskfile
797 fi
798 else
799 # Should this be fatal?
800 warnprint "Failed to bring up vboxnet0!!"
801 fi
802 fi
803 fi
804
805 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
806 infoprint "Configuring services..."
807 if test "$REMOTEINST" -eq 1; then
808 subprint "Skipped for targetted installs."
809 else
810 # Enable Zone access service for non-remote installs, other services (Webservice) are delivered disabled by the manifest class action
811 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" | grep "disabled" 2>/dev/null`
812 if test ! -z "$servicefound"; then
813 /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
814 if test "$?" -eq 0; then
815 subprint "Loaded: Zone access service"
816 else
817 subprint "Loading Zone access service ...FAILED."
818 fi
819 fi
820 fi
821 fi
822
823 # Update mime and desktop databases to get the right menu entries
824 # and icons. There is still some delay until the GUI picks it up,
825 # but that cannot be helped.
826 if test -d $PKG_INSTALL_ROOT/usr/share/icons; then
827 infoprint "Installing MIME types and icons..."
828 if test "$REMOTEINST" -eq 0; then
829 /usr/bin/update-mime-database /usr/share/mime >/dev/null 2>&1
830 /usr/bin/update-desktop-database -q 2>/dev/null
831 else
832 subprint "Skipped for targetted installs."
833 fi
834 fi
835
836 # Install python bindings for non-remote installs
837 if test "$REMOTEINST" -eq 0; then
838 if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
839 PYTHONBIN=`which python 2> /dev/null`
840 if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
841 infoprint "Installing Python bindings..."
842
843 INSTALLEDIT=1
844 PYTHONBIN=`which python2.4 2>/dev/null`
845 install_python_bindings "$PYTHONBIN" "Python 2.4"
846 if test "$?" -eq 0; then
847 INSTALLEDIT=0
848 fi
849 PYTHONBIN=`which python2.5 2>/dev/null`
850 install_python_bindings "$PYTHONBIN" "Python 2.5"
851 if test "$?" -eq 0; then
852 INSTALLEDIT=0
853 fi
854 PYTHONBIN=`which python2.6 2>/dev/null`
855 install_python_bindings "$PYTHONBIN" "Python 2.6"
856 if test "$?" -eq 0; then
857 INSTALLEDIT=0
858 fi
859
860 # remove files installed by Python build
861 rm -rf $DIR_VBOXBASE/sdk/installer/build
862
863 if test "$INSTALLEDIT" -ne 0; then
864 warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
865 warnprint "Skipped installing the Python bindings."
866 fi
867 else
868 warnprint "Python not found, skipped installed Python bindings."
869 fi
870 fi
871 else
872 warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
873 fi
874
875 # Update boot archive
876 infoprint "Updating the boot archive..."
877 if test "$REMOTEINST" -eq 0; then
878 $BIN_BOOTADM update-archive > /dev/null
879 else
880 $BIN_BOOTADM update-archive -R $PKG_INSTALL_ROOT > /dev/null
881 fi
882
883 return 0
884 else
885 errorprint "Failed to install drivers"
886 exit 666
887 fi
888 return 1
889}
890
891# preremove([fatal])
892# failure: depends on [fatal]
893preremove()
894{
895 fatal=$1
896
897 cleanup_install "$fatal"
898
899 remove_drivers "$fatal"
900 if test "$?" -eq 0; then
901 return 0;
902 fi
903 return 1
904}
905
906
907
908# And it begins...
909find_bins
910check_root
911check_isa
912check_zone
913get_sysinfo
914
915if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
916 BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
917 REMOTEINST=1
918fi
919
920# Get command line options
921while test $# -gt 0;
922do
923 case "$1" in
924 --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
925 drvop="$1"
926 ;;
927 --fatal)
928 fatal="$FATALOP"
929 ;;
930 --silent)
931 ISSILENT="$SILENTOP"
932 ;;
933 --ips)
934 ISIPS="$IPSOP"
935 ;;
936 --altkerndir)
937 # Use alternate kernel driver config folder (dev only)
938 DIR_CONF="/usr/kernel/drv"
939 ;;
940 --help)
941 printusage
942 exit 1
943 ;;
944 *)
945 break
946 ;;
947 esac
948 shift
949done
950
951case "$drvop" in
952--postinstall)
953 check_module_arch
954 postinstall
955 ;;
956--preremove)
957 preremove "$fatal"
958 ;;
959--installdrivers)
960 check_module_arch
961 install_drivers
962 ;;
963--removedrivers)
964 remove_drivers "$fatal"
965 ;;
966--setupdrivers)
967 remove_drivers "$fatal"
968 infoprint "Installing VirtualBox drivers:"
969 install_drivers
970 ;;
971*)
972 printusage
973 exit 1
974esac
975
976exit "$?"
977
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