VirtualBox

source: vbox/trunk/src/VBox/Additions/solaris/Installer/postinstall.sh@ 43998

Last change on this file since 43998 was 43998, checked in by vboxsync, 12 years ago

Solaris/Additions: Ship X.Org 1.13 drivers and fixed the installer to handle X.Org versions more generically.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 14.8 KB
Line 
1#!/bin/sh
2#
3# VirtualBox postinstall script for Solaris.
4#
5# Copyright (C) 2008-2010 Oracle Corporation
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# The contents of this file may alternatively be used under the terms
16# of the Common Development and Distribution License Version 1.0
17# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
18# VirtualBox OSE distribution, in which case the provisions of the
19# CDDL are applicable instead of those of the GPL.
20#
21# You may elect to license modified versions of this file under the
22# terms and conditions of either the GPL or the CDDL or both.
23#
24
25# LC_ALL should take precedence over LC_* and LANG but whatever...
26LC_ALL=C
27export LC_ALL
28
29LANG=C
30export LANG
31
32# uncompress(directory, file)
33# Updates package metadata and uncompresses the file.
34uncompress_file()
35{
36 if test -z "$1" || test -z "$2"; then
37 echo "missing argument to uncompress_file()"
38 return 1
39 fi
40
41 # Remove compressed path from the pkg
42 /usr/sbin/removef $PKGINST "$1/$2.Z" 1>/dev/null
43
44 # Add uncompressed path to the pkg
45 /usr/sbin/installf -c none $PKGINST "$1/$2" f
46
47 # Uncompress the file (removes compressed file when done)
48 uncompress -f "$1/$2.Z" > /dev/null 2>&1
49}
50
51# uncompress_files(directory_with_*.Z_files)
52uncompress_files()
53{
54 for i in "${1}/"*.Z; do
55 uncompress_file "${1}" "`basename \"${i}\" .Z`"
56 done
57}
58
59solaris64dir="amd64"
60solaris32dir="i386"
61vboxadditions_path="$BASEDIR/opt/VirtualBoxAdditions"
62vboxadditions32_path=$vboxadditions_path/$solaris32dir
63vboxadditions64_path=$vboxadditions_path/$solaris64dir
64
65# get the current zone
66currentzone=`zonename`
67# get what ISA the guest is running
68cputype=`isainfo -k`
69if test "$cputype" = "amd64"; then
70 isadir=$solaris64dir
71else
72 isadir=""
73fi
74
75vboxadditionsisa_path=$vboxadditions_path/$isadir
76
77
78# uncompress if necessary
79if test -f "$vboxadditions32_path/VBoxClient.Z" || test -f "$vboxadditions64_path/VBoxClient.Z"; then
80 echo "Uncompressing files..."
81 if test -f "$vboxadditions32_path/VBoxClient.Z"; then
82 uncompress_files "$vboxadditions32_path"
83 fi
84 if test -f "$vboxadditions64_path/VBoxClient.Z"; then
85 uncompress_files "$vboxadditions64_path"
86 fi
87fi
88
89
90if test "$currentzone" = "global"; then
91 # vboxguest.sh would've been installed, we just need to call it.
92 echo "Configuring VirtualBox guest kernel module..."
93 # stop all previous moduels (vboxguest, vboxfs) and start only starts vboxguest
94 $vboxadditions_path/vboxguest.sh stopall silentunload
95 $vboxadditions_path/vboxguest.sh start
96
97 sed -e '/name=vboxguest/d' /etc/devlink.tab > /etc/devlink.vbox
98 echo "type=ddi_pseudo;name=vboxguest \D" >> /etc/devlink.vbox
99 mv -f /etc/devlink.vbox /etc/devlink.tab
100
101 # create the device link
102 /usr/sbin/devfsadm -i vboxguest
103fi
104
105
106# check if X.Org exists (snv_130 and higher have /usr/X11/* as /usr/*)
107if test -f "/usr/bin/Xorg"; then
108 xorgbin="/usr/bin/Xorg"
109elif test -f "/usr/X11/bin/Xorg"; then
110 xorgbin="/usr/X11/bin/Xorg"
111else
112 xorgbin=""
113 retval=0
114fi
115
116# create links
117echo "Creating links..."
118if test "$currentzone" = "global"; then
119 /usr/sbin/installf -c none $PKGINST /dev/vboxguest=../devices/pci@0,0/pci80ee,cafe@4:vboxguest s
120 /usr/sbin/installf -c none $PKGINST /dev/vboxms=../devices/pseudo/vboxms@0:vboxms s
121fi
122
123# Install Xorg components to the required places
124if test ! -z "$xorgbin"; then
125 xorgversion_long=`$xorgbin -version 2>&1 | grep "X Window System Version"`
126 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X Window System Version \([^ ]*\)'`
127 if test -z "$xorgversion_long"; then
128 xorgversion_long=`$xorgbin -version 2>&1 | grep "X.Org X Server"`
129 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X.Org X Server \([^ ]*\)'`
130 fi
131
132 # "X.Y.Z" - strip off all numerics after the 2nd '.' character, e.g. "1.11.3" -> "1.11"
133 # Then the next sed, strips of all '.' characters, "1.11" -> "111".
134 fileversion=`echo $xorgversion | sed "s/\.[0-9]*//2" | sed "s/\.//"`
135 vboxvideo_src="vboxvideo_drv_$fileversion.so"
136
137 # Handle exceptions now where the X.org version does not exactly match the file-version.
138 case "$xorgversion" in
139 1.5.99 )
140 vboxvideo_src="vboxvideo_drv_16.so"
141 ;;
142 7.2.* )
143 vboxvideo_src="vboxvideo_drv_71.so"
144 ;;
145 6.9.* )
146 vboxvideo_src="vboxvideo_drv_70.so"
147 ;;
148 esac
149
150 retval=0
151 if test -z "$vboxvideo_src"; then
152 echo "*** Unknown version of the X Window System installed."
153 echo "*** Failed to install the VirtualBox X Window System drivers."
154
155 # Exit as partially failed installation
156 retval=2
157 elif test ! -f "$vboxadditions32_path/$vboxvideo_src" && test ! -f "$vboxadditions64_path/$vboxvideo_src"; then
158 echo "*** $vboxadditions32_path/$vboxvideo_src or $vboxadditions64_path/$vboxvideo_src not found!"
159 echo "*** Failed to install the VirtualBox X.org drivers."
160
161 # Exit as partially failed installation
162 retval=2
163 else
164 echo "Installing video driver for X.Org $xorgversion..."
165
166 # Determine destination paths (snv_130 and above use "/usr/lib/xorg", older use "/usr/X11/lib"
167 vboxvideo32_dest_base="/usr/lib/xorg/modules/drivers"
168 if test ! -d $vboxvideo32_dest_base; then
169 vboxvideo32_dest_base="/usr/X11/lib/modules/drivers"
170 fi
171
172 vboxvideo64_dest_base=$vboxvideo32_dest_base/$solaris64dir
173
174 # snv_163 drops 32-bit support completely, and uses 32-bit locations for the 64-bit stuff. Ugly.
175 # We try to detect this by looking at bitness of "vesa_drv.so", and adjust our destination paths accordingly.
176 # We do not rely on using Xorg -version's ABI output because some builds (snv_162 iirc) have 64-bit ABI with
177 # 32-bit file locations.
178 if test -f "$vboxvideo32_dest_base/vesa_drv.so"; then
179 bitsize=`file "$vboxvideo32_dest_base/vesa_drv.so" | grep -i "32-bit"`
180 skip32="no"
181 else
182 echo "* Warning vesa_drv.so missing. Assuming Xorg ABI is 64-bit..."
183 fi
184
185 if test -z "$bitsize"; then
186 skip32="yes"
187 vboxvideo64_dest_base=$vboxvideo32_dest_base
188 fi
189
190 # Make sure destination path exists
191 if test ! -d $vboxvideo64_dest_base; then
192 echo "*** Missing destination paths for video module. Aborting."
193 echo "*** Failed to install the VirtualBox X Window System driver."
194
195 # Exit as partially failed installation
196 retval=2
197 else
198 # 32-bit x11 drivers
199 if test "$skip32" = "no" && test -f "$vboxadditions32_path/$vboxvideo_src"; then
200 vboxvideo_dest="$vboxvideo32_dest_base/vboxvideo_drv.so"
201 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
202 cp "$vboxadditions32_path/$vboxvideo_src" "$vboxvideo_dest"
203
204 # Removing redundant names from pkg and files from disk
205 /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxvideo_drv_* 1>/dev/null
206 rm -f $vboxadditions32_path/vboxvideo_drv_*
207 fi
208
209 # 64-bit x11 drivers
210 if test -f "$vboxadditions64_path/$vboxvideo_src"; then
211 vboxvideo_dest="$vboxvideo64_dest_base/vboxvideo_drv.so"
212 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
213 cp "$vboxadditions64_path/$vboxvideo_src" "$vboxvideo_dest"
214
215 # Removing redundant names from pkg and files from disk
216 /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxvideo_drv_* 1>/dev/null
217 rm -f $vboxadditions64_path/vboxvideo_drv_*
218 fi
219
220 # Some distros like Indiana have no xorg.conf, deal with this
221 if test ! -f '/etc/X11/xorg.conf' && test ! -f '/etc/X11/.xorg.conf'; then
222
223 # Xorg 1.3.x+ should use the modeline less Xorg confs while older should
224 # use ones with all the video modelines in place. Argh.
225 xorgconf_file="solaris_xorg_modeless.conf"
226 xorgconf_unfit="solaris_xorg.conf"
227 case "$xorgversion" in
228 7.1.* | 7.2.* | 6.9.* | 7.0.* )
229 xorgconf_file="solaris_xorg.conf"
230 xorgconf_unfit="solaris_xorg_modeless.conf"
231 ;;
232 esac
233
234 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_file 1>/dev/null
235 mv -f $vboxadditions_path/$xorgconf_file /etc/X11/.xorg.conf
236
237 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_unfit 1>/dev/null
238 rm -f $vboxadditions_path/$xorgconf_unfit
239 fi
240
241 # Adjust xorg.conf with video driver sections
242 $vboxadditions_path/x11config15sol.pl
243 fi
244 fi
245
246
247 # Setup our VBoxClient
248 echo "Configuring client..."
249 vboxclient_src=$vboxadditions_path
250 vboxclient_dest="/usr/share/gnome/autostart"
251 clientinstalled=0
252 if test -d "$vboxclient_dest"; then
253 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/vboxclient.desktop=$vboxadditions_path/vboxclient.desktop s
254 clientinstalled=1
255 fi
256 vboxclient_dest="/usr/dt/config/Xsession.d"
257 if test -d "$vboxclient_dest"; then
258 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
259 clientinstalled=1
260 fi
261
262 # Try other autostart locations if none of the above ones work
263 if test $clientinstalled -eq 0; then
264 vboxclient_dest="/etc/xdg/autostart"
265 if test -d "$vboxclient_dest"; then
266 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
267 clientinstalled=1
268 else
269 echo "*** Failed to configure client, couldn't find any autostart directory!"
270 # Exit as partially failed installation
271 retval=2
272 fi
273 fi
274else
275 echo "(*) X.Org not found, skipped configuring X.Org guest additions."
276fi
277
278
279# Shared Folder kernel module (different for S10 & Nevada)
280osverstr=`uname -r`
281vboxfsmod="vboxfs"
282vboxfsunused="vboxfs_s10"
283if test "$osverstr" = "5.10"; then
284 vboxfsmod="vboxfs_s10"
285 vboxfsunused="vboxfs"
286fi
287
288# Move the appropriate module to kernel/fs & remove the unused module name from pkg and file from disk
289# 64-bit shared folder module
290if test -f "$vboxadditions64_path/$vboxfsmod"; then
291 echo "Installing 64-bit shared folders module..."
292 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/$solaris64dir/vboxfs" f
293 mv -f $vboxadditions64_path/$vboxfsmod /usr/kernel/fs/$solaris64dir/vboxfs
294 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsmod 1>/dev/null
295 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsunused 1>/dev/null
296 rm -f $vboxadditions64_path/$vboxfsunused
297fi
298
299# 32-bit shared folder module
300if test -f "$vboxadditions32_path/$vboxfsmod"; then
301 echo "Installing 32-bit shared folders module..."
302 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/vboxfs" f
303 mv -f $vboxadditions32_path/$vboxfsmod /usr/kernel/fs/vboxfs
304 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsmod 1>/dev/null
305 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsunused 1>/dev/null
306 rm -f $vboxadditions32_path/$vboxfsunused
307fi
308
309# Add a group "vboxsf" for Shared Folders access
310# All users which want to access the auto-mounted Shared Folders have to
311# be added to this group.
312groupadd vboxsf >/dev/null 2>&1
313
314# install openGL extensions for X.Org
315if test ! -z "$xorgbin"; then
316 # 32-bit crogl opengl library replacement
317 if test -f "/usr/lib/VBoxOGL.so"; then
318 cp -f /usr/X11/lib/mesa/libGL.so.1 /usr/X11/lib/mesa/libGL_original_.so.1
319 ln -sf /usr/lib/VBoxOGL.so /usr/X11/lib/mesa/libGL.so.1
320 fi
321
322 # 64-bit crogl opengl library replacement
323 if test -f "/usr/lib/amd64/VBoxOGL.so"; then
324 cp -f /usr/X11/lib/mesa/amd64/libGL.so.1 /usr/X11/lib/mesa/amd64/libGL_original_.so.1
325 ln -sf /usr/lib/amd64/VBoxOGL.so /usr/X11/lib/mesa/amd64/libGL.so.1
326 fi
327fi
328
329# Move the pointer integration module to kernel/drv & remove the unused module name from pkg and file from disk
330
331# Finalize
332/usr/sbin/removef -f $PKGINST
333/usr/sbin/installf -f $PKGINST
334
335
336if test "$currentzone" = "global"; then
337 /usr/sbin/devfsadm -i vboxguest
338
339 # Setup VBoxService and vboxmslnk and start the services automatically
340 echo "Configuring services (this might take a while)..."
341 cmax=32
342 cslept=0
343 success=0
344 sync
345
346 # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
347 # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
348 # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
349 /usr/sbin/svcadm restart svc:system/manifest-import:default
350 ## @todo why do we redirect to /dev/null and then save the output?
351 is_import=`/usr/bin/svcs virtualbox/vboxservice >/dev/null 2>&1 && /usr/bin/svcs virtualbox/vboxmslnk >/dev/null 2>&1`
352 while test $? -ne 0;
353 do
354 sleep 1
355 cslept=`expr $cslept + 1`
356 if test "$cslept" -eq "$cmax"; then
357 success=1
358 break
359 fi
360 is_import=`/usr/bin/svcs virtualbox/vboxservice >/dev/null 2>&1 && /usr/bin/svcs virtualbox/vboxmslnk >/dev/null 2>&1`
361 done
362 if test "$success" -eq 0; then
363 echo "Enabling services..."
364 /usr/sbin/svcadm enable -s virtualbox/vboxservice
365 /usr/sbin/svcadm enable -s virtualbox/vboxmslnk
366 else
367 echo "## Service import failed."
368 echo "## See /var/svc/log/system-manifest-import:default.log for details."
369 # Exit as partially failed installation
370 retval=2
371 fi
372
373 # Update boot archive
374 BOOTADMBIN=/sbin/bootadm
375 if test -x "$BOOTADMBIN"; then
376 if test -h "/dev/vboxguest"; then
377 echo "Updating boot archive..."
378 $BOOTADMBIN update-archive > /dev/null
379 else
380 echo "## Guest kernel module doesn't seem to be up. Skipped explicit boot-archive update."
381 fi
382 else
383 echo "## $BOOTADMBIN not found/executable. Skipped explicit boot-archive update."
384 fi
385fi
386
387
388echo "Done."
389if test $retval -eq 0; then
390 if test ! -z "$xorgbin"; then
391 echo "Please re-login to activate the X11 guest additions."
392 fi
393 echo "If you have just un-installed the previous guest additions a REBOOT is required."
394fi
395exit $retval
396
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