5
# VirtualBox Configuration Script, Solaris host.
7
# Copyright (C) 2009 Sun Microsystems, Inc.
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.
17
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18
# Clara, CA 95054 USA or visit http://www.sun.com if you need
19
# additional information or have any questions.
23
# Never use exit 2 or exit 20 etc., the return codes are used in
24
# SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
27
HOST_OS_MAJORVERSION=`uname -r`
28
# Which OpenSolaris version (snv_xxx)?
29
HOST_OS_MINORVERSION=`uname -v | sed -e "s/snv_//" -e "s/[^0-9]//"`
31
DIR_VBOXBASE=/opt/VirtualBox
32
DIR_MOD_32="/platform/i86pc/kernel/drv"
33
DIR_MOD_64=$DIR_MOD_32/amd64
35
BIN_ADDDRV=/usr/sbin/add_drv
36
BIN_REMDRV=/usr/sbin/rem_drv
37
BIN_MODLOAD=/usr/sbin/modload
38
BIN_MODUNLOAD=/usr/sbin/modunload
39
BIN_MODINFO=/usr/sbin/modinfo
40
BIN_DEVFSADM=/usr/sbin/devfsadm
41
BIN_BOOTADM=/sbin/bootadm
42
BIN_SVCADM=/usr/sbin/svcadm
43
BIN_SVCCFG=/usr/sbin/svccfg
44
BIN_IFCONFIG=/sbin/ifconfig
46
# "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
51
DESC_VBOXNET="NetAdapter"
54
DESC_VBOXFLT="NetFilter"
56
# No Separate VBI since (3.1)
58
#DESC_VBI="Kernel Interface"
60
MOD_VBOXUSBMON=vboxusbmon
61
DESC_VBOXUSBMON="USBMonitor"
75
if test "$ISSILENT" != "$SILENTOP"; then
82
if test "$ISSILENT" != "$SILENTOP"; then
89
if test "$ISSILENT" != "$SILENTOP"; then
90
echo 1>&2 " * Warning!! $1"
101
# !! failure is always fatal
104
if test -z "$1"; then
105
errorprint "missing argument to check_bin_path()"
109
if test ! -x "$1"; then
110
errorprint "$1 missing or is not an executable"
117
# !! failure is always fatal
120
# Search only for binaries that might be in different locations
121
BIN_IFCONFIG=`which ifconfig 2> /dev/null`
122
BIN_SVCS=`which svcs 2> /dev/null`
124
check_bin_path "$BIN_ADDDRV"
125
check_bin_path "$BIN_REMDRV"
126
check_bin_path "$BIN_MODLOAD"
127
check_bin_path "$BIN_MODUNLOAD"
128
check_bin_path "$BIN_MODINFO"
129
check_bin_path "$BIN_DEVFSADM"
130
check_bin_path "$BIN_BOOTADM"
131
check_bin_path "$BIN_SVCADM"
132
check_bin_path "$BIN_SVCCFG"
133
check_bin_path "$BIN_SVCS"
134
check_bin_path "$BIN_IFCONFIG"
138
# !! failure is always fatal
141
idbin=/usr/xpg4/bin/id
142
if test ! -x "$idbin"; then
143
found=`which id 2> /dev/null`
144
if test ! -x "$found"; then
145
errorprint "Failed to find a suitable user id executable."
152
if test `$idbin -u` -ne 0; then
153
errorprint "This script must be run with administrator privileges."
159
# !! failure is always fatal
162
currentzone=`zonename`
163
if test "$currentzone" != "global"; then
164
errorprint "This script must be run from the global zone."
170
# !! failure is always fatal
173
currentisa=`uname -i`
174
if test "$currentisa" = "i86xpv"; then
175
errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
180
# check_module_arch()
181
# !! failure is always fatal
185
if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
186
errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
191
# module_added(modname)
192
# returns 1 if added, 0 otherwise
195
if test -z "$1"; then
196
errorprint "missing argument to module_added()"
200
loadentry=`cat /etc/name_to_major | grep $1`
201
if test -z "$loadentry"; then
207
# module_loaded(modname)
208
# returns 1 if loaded, 0 otherwise
211
if test -z "$1"; then
212
errorprint "missing argument to module_loaded()"
217
# modinfo should now work properly since we prevent module autounloading
218
loadentry=`$BIN_MODINFO | grep $modname`
219
if test -z "$loadentry"; then
225
# add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
226
# failure: depends on "fatal"
229
if test -z "$1" || test -z "$2"; then
230
errorprint "missing argument to add_driver()"
240
if test -n "$modperm"; then
241
if test "$nullop" = "$NULLOP"; then
242
$BIN_ADDDRV -m"$modperm" $modname >/dev/null 2>&1
244
$BIN_ADDDRV -m"$modperm" $modname
247
if test "$nullop" = "$NULLOP"; then
248
$BIN_ADDDRV $modname >/dev/null 2>&1
254
if test $? -ne 0; then
255
subprint "Adding: $moddesc module ...FAILED!"
256
if test "$fatal" = "$FATALOP"; then
264
# rem_driver(modname, moddesc, [fatal])
265
# failure: depends on [fatal]
268
if test -z "$1" || test -z "$2"; then
269
errorprint "missing argument to rem_driver()"
276
module_added $modname
277
if test "$?" -eq 0; then
278
if test "$ISIPS" != "$IPSOP"; then
281
$BIN_REMDRV $modname >/dev/null 2>&1
283
if test $? -eq 0; then
284
subprint "Removed: $moddesc module"
287
subprint "Removing: $moddesc ...FAILED!"
288
if test "$fatal" = "$FATALOP"; then
296
# unload_module(modname, moddesc, [fatal])
300
if test -z "$1" || test -z "$2"; then
301
errorprint "missing argument to unload_module()"
308
modid=`$BIN_MODINFO | grep $modname | cut -f 1 -d ' ' `
309
if test -n "$modid"; then
310
$BIN_MODUNLOAD -i $modid
311
if test $? -eq 0; then
312
subprint "Unloaded: $moddesc module"
314
subprint "Unloading: $moddesc ...FAILED!"
315
if test "$fatal" = "$FATALOP"; then
324
# load_module(modname, moddesc, [fatal])
325
# pass "drv/modname" or "misc/vbi" etc.
329
if test -z "$1" || test -z "$2"; then
330
errorprint "missing argument to load_module()"
337
$BIN_MODLOAD -p $modname
338
if test $? -eq 0; then
339
subprint "Loaded: $moddesc module"
342
subprint "Loading: $moddesc ...FAILED!"
343
if test "$fatal" = "$FATALOP"; then
351
# !! failure is always fatal
354
if test -n "_HARDENED_"; then
355
add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys'"
357
add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
359
load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
361
# Add vboxdrv to devlink.tab
362
sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
363
echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
364
mv -f /etc/devlink.vbox /etc/devlink.tab
366
# Create the device link
367
/usr/sbin/devfsadm -i "$MOD_VBOXDRV"
369
if test $? -eq 0 && test -h "/dev/vboxdrv"; then
371
if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
372
add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
373
load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
376
if test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
377
add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
378
load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
381
if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$HOST_OS_MAJORVERSION" != "5.10"; then
382
# For VirtualBox 3.1 the new USB code requires Nevada > 123
383
if test "$HOST_OS_MINORVERSION" -gt 123; then
384
add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
385
load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
387
# Add vboxusbmon to devlink.tab
388
sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
389
echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
390
mv -f /etc/devlink.vbox /etc/devlink.tab
392
# Create the device link
393
/usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
394
if test $? -ne 0; then
395
errorprint "Failed to create device link for $MOD_VBOXUSBMON."
399
# Add vboxusb if present
400
# This driver is special, we need it in the boot-archive but since there is no
401
# USB device to attach to now (it's done at runtime) it will fail to attach so
402
# redirect attaching failure output to /dev/null
403
if test -f /platform/i86pc/kernel/drv/vboxusb.conf; then
404
add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
405
load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
408
warnprint "Solaris 5.11 snv_124 or higher required for USB support. Skipped installing USB support."
412
errorprint "Failed to create device link for $MOD_VBOXDRV."
419
# remove_all([fatal])
420
# failure: depends on [fatal]
425
# Remove vboxdrv from devlink.tab
426
devlinkfound=`cat /etc/devlink.tab | grep vboxdrv`
427
if test -n "$devlinkfound"; then
428
sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
429
mv -f /etc/devlink.vbox /etc/devlink.tab
432
# Remove vboxusbmon from devlink.tab
433
devlinkfound=`cat /etc/devlink.tab | grep vboxusbmon`
434
if test -n "$devlinkfound"; then
435
sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
436
mv -f /etc/devlink.vbox /etc/devlink.tab
439
unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
440
rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
442
unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
443
rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
445
unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
446
rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
448
unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
449
rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
451
unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
452
rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
454
# No separate VBI since 3.1
455
# unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
458
if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then
461
if test -h "/dev/vboxusbmon" || test -f "/dev/vboxusbmon"; then
462
rm -f /dev/vboxusbmon
465
# unpatch nwam/dhcpagent fix
466
nwamfile=/etc/nwam/llp
467
nwambackupfile=$nwamfile.vbox
468
if test -f "$nwamfile"; then
469
sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
470
mv -f $nwambackupfile $nwamfile
476
# install_python_bindings(pythonbin)
477
# remarks: changes pwd
479
install_python_bindings()
481
# The python binary might not be there, so just exit silently
482
if test -z "$1"; then
486
if test -z "$2"; then
487
errorprint "missing argument to install_python_bindings"
493
if test -x "$pythonbin"; then
494
VBOX_INSTALL_PATH="$DIR_VBOXBASE"
495
export VBOX_INSTALL_PATH
496
cd $DIR_VBOXBASE/sdk/installer
497
$pythonbin ./vboxapisetup.py install > /dev/null
498
if test "$?" -eq 0; then
499
subprint "Installed: Bindings for $pythondesc"
507
# cleanup_install([fatal])
508
# failure: depends on [fatal]
513
# stop and unregister webservice SMF
514
servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
515
if test ! -z "$servicefound"; then
516
$BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
517
$BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
518
if test "$?" -eq 0; then
519
subprint "Unloaded: Web service"
521
subprint "Unloading: Web service ...ERROR(S)."
525
# stop and unregister zoneaccess SMF
526
servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
527
if test ! -z "$servicefound"; then
528
$BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
529
$BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
530
if test "$?" -eq 0; then
531
subprint "Unloaded: Zone access service"
533
subprint "Unloading: Zone access service ...ERROR(S)."
538
vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
539
if test "$?" -eq 0; then
540
$BIN_IFCONFIG vboxnet0 unplumb
541
if test "$?" -ne 0; then
542
errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
543
if test "$fatal" = "$FATALOP"; then
549
# unplumb vboxnet0 ipv6
550
vboxnetup=`$BIN_IFCONFIG vboxnet0 inet6 >/dev/null 2>&1`
551
if test "$?" -eq 0; then
552
$BIN_IFCONFIG vboxnet0 inet6 unplumb
553
if test "$?" -ne 0; then
554
errorprint "VirtualBox NetAdapter 'vboxnet0' IPv6 couldn't be unplumbed (probably in use)."
555
if test "$fatal" = "$FATALOP"; then
564
# !! failure is always fatal
567
infoprint "Loading VirtualBox kernel modules..."
570
if test "$?" -eq 0; then
571
if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
573
nwamfile=/etc/nwam/llp
574
nwambackupfile=$nwamfile.vbox
575
if test -f "$nwamfile"; then
576
sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
577
echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
578
mv -f $nwambackupfile $nwamfile
581
# plumb and configure vboxnet0
582
$BIN_IFCONFIG vboxnet0 plumb up
583
if test "$?" -eq 0; then
584
$BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
586
# Should this be fatal?
587
warnprint "Failed to bring up vboxnet0!!"
591
if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
592
infoprint "Configuring services..."
596
if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml; then
597
/usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml
598
/usr/sbin/svcadm disable -s svc:/application/virtualbox/webservice:default
599
if test "$?" -eq 0; then
600
subprint "Loaded: Web service"
602
subprint "Loading: Web service ...ERROR(S)."
606
# Zone access service
607
if test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
608
/usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
609
/usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
610
if test "$?" -eq 0; then
611
subprint "Loaded: Zone access service"
613
subprint "Loading: Zone access service ...ERROR(S)."
617
# Install python bindings
618
if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
619
PYTHONBIN=`which python 2> /dev/null`
620
if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
621
infoprint "Installing Python bindings..."
624
PYTHONBIN=`which python2.4 2>/dev/null`
625
install_python_bindings "$PYTHONBIN" "Python 2.4"
626
if test "$?" -eq 0; then
629
PYTHONBIN=`which python2.5 2>/dev/null`
630
install_python_bindings "$PYTHONBIN" "Python 2.5"
631
if test "$?" -eq 0; then
634
PYTHONBIN=`which python2.6 2>/dev/null`
635
install_python_bindings "$PYTHONBIN" "Python 2.6"
636
if test "$?" -eq 0; then
640
# remove files installed by Python build
641
rm -rf $DIR_VBOXBASE/sdk/installer/build
643
if test "$INSTALLEDIT" -ne 0; then
644
warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
645
warnprint "Skipped installing the Python bindings."
648
warnprint "Python not found, skipped installed Python bindings."
652
# Update boot archive
653
infoprint "Updating the boot archive..."
654
$BIN_BOOTADM update-archive > /dev/null
658
errorprint "Failed to update boot-archive"
665
# failure: depends on [fatal]
670
cleanup_install "$fatal"
672
remove_drivers "$fatal"
673
if test "$?" -eq 0; then
687
# Get command line options
691
--postinstall | --preremove | --installdrivers | --removedrivers)
723
remove_drivers "$fatal"
726
errorprint "Invalid operation $drvop"