~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Installer/solaris/ipsinstall.sh

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
## @file
3
 
# Sun VirtualBox - Manual IPS/pkg(5) postinstall script for Solaris.
4
 
#
5
 
# If you just installed VirtualBox using IPS/pkg(5), you should run this
6
 
# script once to avoid rebooting the system before using VirtualBox.
7
 
#
8
 
 
9
 
#
10
 
# Copyright (C) 2009 Sun Microsystems, Inc.
11
 
#
12
 
# This file is part of VirtualBox Open Source Edition (OSE), as
13
 
# available from http://www.virtualbox.org. This file is free software;
14
 
# you can redistribute it and/or modify it under the terms of the GNU
15
 
# General Public License (GPL) as published by the Free Software
16
 
# Foundation, in version 2 as it comes in the "COPYING" file of the
17
 
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18
 
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
 
#
20
 
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21
 
# Clara, CA 95054 USA or visit http://www.sun.com if you need
22
 
# additional information or have any questions.
23
 
#
24
 
 
25
 
check_root()
26
 
{
27
 
    idbin=/usr/xpg4/bin/id
28
 
    if test ! -f "$idbin"; then
29
 
        found=`which id`
30
 
        if test ! -f "$found" || test ! -h "$found"; then
31
 
            echo "## Failed to find a suitable user id binary."
32
 
            exit 1
33
 
        else
34
 
            idbin=$found
35
 
        fi
36
 
    fi
37
 
 
38
 
    if test `$idbin -u` -ne 0; then
39
 
        echo "## This script must be run with administrator privileges."
40
 
        exit 2
41
 
    fi
42
 
}
43
 
 
44
 
check_zone()
45
 
{
46
 
    currentzone=`zonename`
47
 
    if test "$currentzone" != "global"; then
48
 
        echo "## This script must be run from the global zone."
49
 
        exit 3
50
 
    fi
51
 
}
52
 
 
53
 
install_python_bindings()
54
 
{
55
 
    PYTHONBIN=$1
56
 
    if test -x "$PYTHONBIN"; then
57
 
        VBOX_INSTALL_PATH=/opt/VirtualBox
58
 
        export VBOX_INSTALL_PATH
59
 
        cd /opt/VirtualBox/sdk/installer
60
 
        $PYTHONBIN ./vboxapisetup.py install > /dev/null
61
 
        return 0
62
 
    fi
63
 
    return 1
64
 
}
65
 
 
66
 
check_root
67
 
check_zone
68
 
 
69
 
osversion=`uname -r`
70
 
 
71
 
BIN_REMDRV=/usr/sbin/rem_drv
72
 
BIN_ADDDRV=/usr/sbin/add_drv
73
 
BIN_MODLOAD=/usr/sbin/modload
74
 
BIN_DEVFSADM=/usr/sbin/devfsadm
75
 
 
76
 
# Halt services in case of installation update
77
 
zoneaccessfound=`svcs -a | grep "virtualbox/zoneaccess"`
78
 
if test ! -z "$zoneaccessfound"; then
79
 
    /usr/sbin/svcadm disable -s svc:/application/virtualbox/zoneaccess
80
 
fi
81
 
 
82
 
# Remove drivers ignoring errors as they are not really loaded
83
 
# just updated various boot archive files without really loading
84
 
# them... But we _want_ them to be loaded.
85
 
echo "Removing stale driver configurations..."
86
 
 
87
 
$BIN_REMDRV vboxflt > /dev/null 2>&1
88
 
/sbin/ifconfig vboxnet0 unplumb > /dev/null 2>&1
89
 
$BIN_REMDRV vboxnet > /dev/null 2>&1
90
 
$BIN_REMDRV vboxusbmon > /dev/null 2>&1
91
 
$BIN_REMDRV vboxdrv > /dev/null 2>&1
92
 
 
93
 
echo "Loading VirtualBox Drivers:"
94
 
# Add drivers the proper way and load them immediately
95
 
/opt/VirtualBox/vboxdrv.sh start
96
 
rc=$?
97
 
if test "$rc" -eq 0; then
98
 
    # Add vboxdrv to the devlink.tab
99
 
    sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
100
 
    echo "type=ddi_pseudo;name=vboxdrv  \D" >> /etc/devlink.vbox
101
 
    mv -f /etc/devlink.vbox /etc/devlink.tab
102
 
 
103
 
    # Create the device link
104
 
    /usr/sbin/devfsadm -i vboxdrv
105
 
    rc=$?
106
 
 
107
 
    if test "$rc" -eq 0; then
108
 
        # Load VBoxNetAdapter vboxnet
109
 
        if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
110
 
            /opt/VirtualBox/vboxdrv.sh netstart
111
 
            rc=$?
112
 
 
113
 
            if test "$rc" -eq 0; then
114
 
                # nwam/dhcpagent fix
115
 
                nwamfile=/etc/nwam/llp
116
 
                nwambackupfile=$nwamfile.vbox
117
 
                if test -f "$nwamfile"; then
118
 
                    sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
119
 
                    echo "vboxnet0      static 192.168.56.1" >> $nwambackupfile
120
 
                    mv -f $nwambackupfile $nwamfile
121
 
                    echo "   -> patched /etc/nwam/llp to use static IP for vboxnet0"
122
 
                fi
123
 
            fi
124
 
        fi
125
 
    else
126
 
        echo "## Failed to create device link in /dev for vboxdrv"
127
 
    fi
128
 
 
129
 
    # Load VBoxNetFilter vboxflt
130
 
    if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
131
 
        /opt/VirtualBox/vboxdrv.sh fltstart
132
 
        rc=$?
133
 
    fi
134
 
 
135
 
    # Load VBoxUSBMonitor vboxusbmon (do NOT load for Solaris 10)
136
 
    if test "$rc" -eq 0 && test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$osversion" != "5.10"; then
137
 
        /opt/VirtualBox/vboxdrv.sh usbstart
138
 
        rc=$?
139
 
        if test "$rc" -eq 0; then
140
 
 
141
 
            # Add vboxusbmon to the devlink.tab
142
 
            sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
143
 
            echo "type=ddi_pseudo;name=vboxusbmon       \D" >> /etc/devlink.vbox
144
 
            mv -f /etc/devlink.vbox /etc/devlink.tab
145
 
 
146
 
            /usr/sbin/devfsadm -i vboxusbmon
147
 
            rc=$?
148
 
            if test "$rc" -ne 0; then
149
 
                echo "## Failed to create device link in /dev for vboxusbmon"
150
 
            fi
151
 
        fi
152
 
    fi
153
 
fi
154
 
 
155
 
rc2=0
156
 
if test -f "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
157
 
    /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
158
 
    rc2=$?
159
 
    if test "$rc2" -eq 0; then
160
 
        /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
161
 
        rc2=$?
162
 
        if test "$rc2" -eq 0; then
163
 
            echo "Enabled VirtualBox zone service."
164
 
        else
165
 
            echo "## Failed to enable VirtualBox zone service."
166
 
        fi
167
 
    else
168
 
        echo "## Failed to import VirtualBox zone service."
169
 
    fi
170
 
fi
171
 
 
172
 
# We need to touch the desktop link in order to add it to the menu right away
173
 
if test -f "/usr/share/applications/virtualbox.desktop"; then
174
 
    touch /usr/share/applications/virtualbox.desktop
175
 
    echo "Added VirtualBox shortcut menu item."
176
 
fi
177
 
 
178
 
# Install python bindings
179
 
rc3=0
180
 
if test -f "/opt/VirtualBox/sdk/installer/vboxapisetup.py" || test -h "/opt/VirtualBox/sdk/installer/vboxapisetup.py"; then
181
 
    PYTHONBIN=`which python`
182
 
    if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
183
 
        echo "Installing Python bindings..."
184
 
 
185
 
        INSTALLEDIT=1
186
 
        PYTHONBIN=`which python2.4`
187
 
        install_python_bindings "$PYTHONBIN"
188
 
        if test "$?" -eq 0; then
189
 
            INSTALLEDIT=0
190
 
        fi
191
 
        PYTHONBIN=`which python2.5`
192
 
        install_python_bindings "$PYTHONBIN"
193
 
        if test "$?" -eq 0; then
194
 
            INSTALLEDIT=0
195
 
        fi
196
 
        PYTHONBIN=`which python2.6`
197
 
        install_python_bindings "$PYTHONBIN"
198
 
        if test "$?" -eq 0; then 
199
 
            INSTALLEDIT=0
200
 
        fi
201
 
 
202
 
        # remove files installed by Python build
203
 
        rm -rf /opt/VirtualBox/sdk/installer/build
204
 
 
205
 
        if test "$INSTALLEDIT" -ne 0; then
206
 
            echo "** No suitable Python version found. Requires Python 2.4, 2.5 or 2.6."
207
 
        fi
208
 
        rc3=$INSTALLEDIT
209
 
    else
210
 
        echo "** WARNING! Python not found, skipped installed Python bindings."
211
 
        echo "   Manually run '/opt/VirtualBox/sdk/installer/vboxapisetup.py install'"
212
 
        echo "   to install the bindings when python is available."
213
 
        rc3=1
214
 
    fi
215
 
fi
216
 
 
217
 
# Update boot archive (only when driver's were all successfully loaded)
218
 
rc4=0
219
 
if test "$rc" -eq 0; then
220
 
    BOOTADMBIN=/sbin/bootadm
221
 
    if test -f "$BOOTADMBIN" || test -h "$BOOTADMBIN"; then
222
 
        echo "Updating boot archive..."
223
 
        $BOOTADMBIN update-archive > /dev/null
224
 
        rc4=$?
225
 
    fi
226
 
fi
227
 
 
228
 
echo "Done."
229
 
if test "$rc" -eq 0 && test "$rc2" -eq 0 && test "$rc3" -eq 0 && test "$rc4" -eq 0; then
230
 
    echo "Post install successfully completed."
231
 
else
232
 
    echo "Post install completed but with some errors."
233
 
    # 20 - partially failed installed
234
 
    $rc=20
235
 
fi
236
 
exit $rc
237