VirtualBox

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

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

Additions/Solaris: fix ABI detection with differing locales.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 15.7 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# uncompress(directory, file)
26# Updates package metadata and uncompresses the file.
27uncompress_file()
28{
29 if test -z "$1" || test -z "$2"; then
30 echo "missing argument to uncompress_file()"
31 return 1
32 fi
33
34 # Remove compressed path from the pkg
35 /usr/sbin/removef $PKGINST "$1/$2.Z" 1>/dev/null
36
37 # Add uncompressed path to the pkg
38 /usr/sbin/installf -c none $PKGINST "$1/$2" f
39
40 # Uncompress the file (removes compressed file when done)
41 uncompress -f "$1/$2.Z" > /dev/null 2>&1
42}
43
44uncompress_files()
45{
46 # VBox guest files
47 uncompress_file "$1" "VBoxClient"
48 uncompress_file "$1" "VBoxService"
49 uncompress_file "$1" "VBoxControl"
50
51 # VBox Xorg Video drivers
52 uncompress_file "$1" "vboxvideo_drv_13.so"
53 uncompress_file "$1" "vboxvideo_drv_14.so"
54 uncompress_file "$1" "vboxvideo_drv_15.so"
55 uncompress_file "$1" "vboxvideo_drv_16.so"
56 uncompress_file "$1" "vboxvideo_drv_17.so"
57 uncompress_file "$1" "vboxvideo_drv_18.so"
58 uncompress_file "$1" "vboxvideo_drv_19.so"
59 uncompress_file "$1" "vboxvideo_drv_110.so"
60 uncompress_file "$1" "vboxvideo_drv_70.so"
61 uncompress_file "$1" "vboxvideo_drv_71.so"
62
63 # VBox Xorg Mouse drivers
64 uncompress_file "$1" "vboxmouse_drv_13.so"
65 uncompress_file "$1" "vboxmouse_drv_14.so"
66 uncompress_file "$1" "vboxmouse_drv_15.so"
67 uncompress_file "$1" "vboxmouse_drv_16.so"
68 uncompress_file "$1" "vboxmouse_drv_17.so"
69 uncompress_file "$1" "vboxmouse_drv_18.so"
70 uncompress_file "$1" "vboxmouse_drv_19.so"
71 uncompress_file "$1" "vboxmouse_drv_110.so"
72 uncompress_file "$1" "vboxmouse_drv_70.so"
73 uncompress_file "$1" "vboxmouse_drv_71.so"
74}
75
76solaris64dir="amd64"
77solaris32dir="i386"
78vboxadditions_path="$BASEDIR/opt/VirtualBoxAdditions"
79vboxadditions32_path=$vboxadditions_path/$solaris32dir
80vboxadditions64_path=$vboxadditions_path/$solaris64dir
81
82# get the current zone
83currentzone=`zonename`
84# get what ISA the guest is running
85cputype=`isainfo -k`
86if test "$cputype" = "amd64"; then
87 isadir=$solaris64dir
88else
89 isadir=""
90fi
91
92vboxadditionsisa_path=$vboxadditions_path/$isadir
93
94
95# uncompress if necessary
96if test -f "$vboxadditions32_path/VBoxClient.Z" || test -f "$vboxadditions64_path/VBoxClient.Z"; then
97 echo "Uncompressing files..."
98 if test -f "$vboxadditions32_path/VBoxClient.Z"; then
99 uncompress_files "$vboxadditions32_path"
100 fi
101 if test -f "$vboxadditions64_path/VBoxClient.Z"; then
102 uncompress_files "$vboxadditions64_path"
103 fi
104fi
105
106
107if test "$currentzone" = "global"; then
108 # vboxguest.sh would've been installed, we just need to call it.
109 echo "Configuring VirtualBox guest kernel module..."
110 $vboxadditions_path/vboxguest.sh restartall silentunload
111
112 sed -e '/name=vboxguest/d' /etc/devlink.tab > /etc/devlink.vbox
113 echo "type=ddi_pseudo;name=vboxguest \D" >> /etc/devlink.vbox
114 mv -f /etc/devlink.vbox /etc/devlink.tab
115
116 # create the device link
117 /usr/sbin/devfsadm -i vboxguest
118fi
119
120
121# check if X.Org exists (snv_130 and higher have /usr/X11/* as /usr/*)
122if test -f "/usr/bin/Xorg"; then
123 xorgbin="/usr/bin/Xorg"
124elif test -f "/usr/X11/bin/Xorg"; then
125 xorgbin="/usr/X11/bin/Xorg"
126else
127 xorgbin=""
128 retval=0
129fi
130
131# create links
132echo "Creating links..."
133if test "$currentzone" = "global"; then
134 /usr/sbin/installf -c none $PKGINST /dev/vboxguest=../devices/pci@0,0/pci80ee,cafe@4:vboxguest s
135fi
136
137# Install Xorg components to the required places
138if test ! -z "$xorgbin"; then
139 xorgversion_long=`$xorgbin -version 2>&1 | grep "X Window System Version"`
140 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X Window System Version \([^ ]*\)'`
141 if test -z "$xorgversion_long"; then
142 xorgversion_long=`$xorgbin -version 2>&1 | grep "X.Org X Server"`
143 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X.Org X Server \([^ ]*\)'`
144 fi
145
146 vboxmouse_src=""
147 vboxvideo_src=""
148
149 case "$xorgversion" in
150 1.3.* )
151 vboxmouse_src="vboxmouse_drv_71.so"
152 vboxvideo_src="vboxvideo_drv_13.so"
153 ;;
154 1.4.* )
155 vboxmouse_src="vboxmouse_drv_14.so"
156 vboxvideo_src="vboxvideo_drv_14.so"
157 ;;
158 1.5.99 | 1.6.* )
159 vboxmouse_src="vboxmouse_drv_16.so"
160 vboxvideo_src="vboxvideo_drv_16.so"
161 ;;
162 1.5.* )
163 vboxmouse_src="vboxmouse_drv_15.so"
164 vboxvideo_src="vboxvideo_drv_15.so"
165 ;;
166 1.7.*)
167 vboxmouse_src="vboxmouse_drv_17.so"
168 vboxvideo_src="vboxvideo_drv_17.so"
169 ;;
170 1.8.*)
171 vboxmouse_src="vboxmouse_drv_18.so"
172 vboxvideo_src="vboxvideo_drv_18.so"
173 ;;
174 1.9.*)
175 vboxmouse_src="vboxmouse_drv_19.so"
176 vboxvideo_src="vboxvideo_drv_19.so"
177 ;;
178 1.10.*)
179 vboxmouse_src="vboxmouse_drv_110.so"
180 vboxvideo_src="vboxvideo_drv_110.so"
181 ;;
182 7.1.* | *7.2.* )
183 vboxmouse_src="vboxmouse_drv_71.so"
184 vboxvideo_src="vboxvideo_drv_71.so"
185 ;;
186 6.9.* | 7.0.* )
187 vboxmouse_src="vboxmouse_drv_70.so"
188 vboxvideo_src="vboxvideo_drv_70.so"
189 ;;
190 esac
191
192 retval=0
193 if test -z "$vboxmouse_src"; then
194 echo "*** Unknown version of the X Window System installed."
195 echo "*** Failed to install the VirtualBox X Window System drivers."
196
197 # Exit as partially failed installation
198 retval=2
199 else
200 echo "Installing mouse and video drivers for X.Org $xorgversion..."
201
202 # Determine destination paths (snv_130 and above use "/usr/lib/xorg", older use "/usr/X11/lib"
203 vboxmouse32_dest_base="/usr/lib/xorg/modules/input"
204 if test ! -d $vboxmouse32_dest_base; then
205 vboxmouse32_dest_base="/usr/X11/lib/modules/input"
206 fi
207 vboxvideo32_dest_base="/usr/lib/xorg/modules/drivers"
208 if test ! -d $vboxvideo32_dest_base; then
209 vboxvideo32_dest_base="/usr/X11/lib/modules/drivers"
210 fi
211
212 vboxmouse64_dest_base=$vboxmouse32_dest_base/$solaris64dir
213 vboxvideo64_dest_base=$vboxvideo32_dest_base/$solaris64dir
214
215 # snv_163 drops 32-bit support completely, and uses 32-bit locations for the 64-bit stuff. Ugly.
216 # We try to detect this by looking at bitness of "mouse_drv.so", and adjust our destination paths accordingly.
217 # We do not rely on using Xorg -version's ABI output because some builds (snv_162 iirc) have 64-bit ABI with
218 # 32-bit file locations.
219 bitsize=`file $vboxmouse32_dest_base/mouse_drv.so | grep -i "32-bit"`
220 skip32="no"
221 if test -z "$bitsize"; then
222 skip32="yes"
223 vboxmouse64_dest_base=$vboxmouse32_dest_base
224 vboxvideo64_dest_base=$vboxvideo32_dest_base
225 fi
226
227 # Make sure destination path exists
228 if test ! -d $vboxmouse32_dest_base || test ! -d $vboxvideo32_dest_base || test ! -d $vboxmouse64_dest_base || test ! -d $vboxvideo64_dest_base; then
229 echo "*** Missing destination paths for mouse or video modules. Aborting."
230 echo "*** Failed to install the VirtualBox X Window System drivers."
231
232 # Exit as partially failed installation
233 retval=2
234 else
235 # 32-bit x11 drivers
236 if test "$skip32" = "no" && test -f "$vboxadditions32_path/$vboxmouse_src"; then
237 vboxmouse_dest="$vboxmouse32_dest_base/vboxmouse_drv.so"
238 vboxvideo_dest="$vboxvideo32_dest_base/vboxvideo_drv.so"
239 /usr/sbin/installf -c none $PKGINST "$vboxmouse_dest" f
240 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
241 cp "$vboxadditions32_path/$vboxmouse_src" "$vboxmouse_dest"
242 cp "$vboxadditions32_path/$vboxvideo_src" "$vboxvideo_dest"
243
244 # Removing redundant names from pkg and files from disk
245 /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxmouse_drv_* 1>/dev/null
246 /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxvideo_drv_* 1>/dev/null
247 rm -f $vboxadditions32_path/vboxmouse_drv_*
248 rm -f $vboxadditions32_path/vboxvideo_drv_*
249 fi
250
251 # 64-bit x11 drivers
252 if test -f "$vboxadditions64_path/$vboxmouse_src"; then
253 vboxmouse_dest="$vboxmouse64_dest_base/vboxmouse_drv.so"
254 vboxvideo_dest="$vboxvideo64_dest_base/vboxvideo_drv.so"
255 /usr/sbin/installf -c none $PKGINST "$vboxmouse_dest" f
256 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
257 cp "$vboxadditions64_path/$vboxmouse_src" "$vboxmouse_dest"
258 cp "$vboxadditions64_path/$vboxvideo_src" "$vboxvideo_dest"
259
260 # Removing redundant names from pkg and files from disk
261 /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxmouse_drv_* 1>/dev/null
262 /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxvideo_drv_* 1>/dev/null
263 rm -f $vboxadditions64_path/vboxmouse_drv_*
264 rm -f $vboxadditions64_path/vboxvideo_drv_*
265 fi
266
267 # Some distros like Indiana have no xorg.conf, deal with this
268 if test ! -f '/etc/X11/xorg.conf' && test ! -f '/etc/X11/.xorg.conf'; then
269
270 # Xorg 1.3.x+ should use the modeline less Xorg confs while older should
271 # use ones with all the video modelines in place. Argh.
272 xorgconf_file="solaris_xorg_modeless.conf"
273 xorgconf_unfit="solaris_xorg.conf"
274 case "$xorgversion" in
275 7.1.* | 7.2.* | 6.9.* | 7.0.* )
276 xorgconf_file="solaris_xorg.conf"
277 xorgconf_unfit="solaris_xorg_modeless.conf"
278 ;;
279 esac
280
281 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_file 1>/dev/null
282 mv -f $vboxadditions_path/$xorgconf_file /etc/X11/.xorg.conf
283
284 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_unfit 1>/dev/null
285 rm -f $vboxadditions_path/$xorgconf_unfit
286 fi
287 case "$xorgversion" in
288 7.1.* | 7.2.* | 6.9.* | 7.0.* | 1.3.* )
289 $vboxadditions_path/x11config.pl
290 ;;
291 1.4.* | 1.5.* | 1.6.* | 1.7.* | 1.8.* | 1.9.* | 1.10.*)
292 $vboxadditions_path/x11config15sol.pl
293 ;;
294 esac
295 fi
296 fi
297
298
299 # Setup our VBoxClient
300 echo "Configuring client..."
301 vboxclient_src=$vboxadditions_path
302 vboxclient_dest="/usr/share/gnome/autostart"
303 clientinstalled=0
304 if test -d "$vboxclient_dest"; then
305 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/vboxclient.desktop=$vboxadditions_path/vboxclient.desktop s
306 clientinstalled=1
307 fi
308 vboxclient_dest="/usr/dt/config/Xsession.d"
309 if test -d "$vboxclient_dest"; then
310 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
311 clientinstalled=1
312 fi
313
314 # Try other autostart locations if none of the above ones work
315 if test $clientinstalled -eq 0; then
316 vboxclient_dest="/etc/xdg/autostart"
317 if test -d "$vboxclient_dest"; then
318 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
319 clientinstalled=1
320 else
321 echo "*** Failed to configure client, couldn't find any autostart directory!"
322 # Exit as partially failed installation
323 retval=2
324 fi
325 fi
326else
327 echo "(*) X.Org not found, skipped configuring X.Org guest additions."
328fi
329
330
331# Shared Folder kernel module (different for S10 & Nevada)
332osverstr=`uname -r`
333vboxfsmod="vboxfs"
334vboxfsunused="vboxfs_s10"
335if test "$osverstr" = "5.10"; then
336 vboxfsmod="vboxfs_s10"
337 vboxfsunused="vboxfs"
338fi
339
340# Move the appropriate module to kernel/fs & remove the unused module name from pkg and file from disk
341# 64-bit shared folder module
342if test -f "$vboxadditions64_path/$vboxfsmod"; then
343 echo "Installing 64-bit shared folders module..."
344 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/$solaris64dir/vboxfs" f
345 mv -f $vboxadditions64_path/$vboxfsmod /usr/kernel/fs/$solaris64dir/vboxfs
346 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsmod 1>/dev/null
347 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsunused 1>/dev/null
348 rm -f $vboxadditions64_path/$vboxfsunused
349fi
350
351# 32-bit shared folder module
352if test -f "$vboxadditions32_path/$vboxfsmod"; then
353 echo "Installing 32-bit shared folders module..."
354 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/vboxfs" f
355 mv -f $vboxadditions32_path/$vboxfsmod /usr/kernel/fs/vboxfs
356 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsmod 1>/dev/null
357 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsunused 1>/dev/null
358 rm -f $vboxadditions32_path/$vboxfsunused
359fi
360
361# Add a group "vboxsf" for Shared Folders access
362# All users which want to access the auto-mounted Shared Folders have to
363# be added to this group.
364groupadd vboxsf >/dev/null 2>&1
365
366# install openGL extensions for X.Org
367if test ! -z "$xorgbin"; then
368 # 32-bit crogl opengl library replacement
369 if test -f "/usr/lib/VBoxOGL.so"; then
370 cp -f /usr/X11/lib/mesa/libGL.so.1 /usr/X11/lib/mesa/libGL_original_.so.1
371 ln -sf /usr/lib/VBoxOGL.so /usr/X11/lib/mesa/libGL.so.1
372 fi
373
374 # 64-bit crogl opengl library replacement
375 if test -f "/usr/lib/amd64/VBoxOGL.so"; then
376 cp -f /usr/X11/lib/mesa/amd64/libGL.so.1 /usr/X11/lib/mesa/amd64/libGL_original_.so.1
377 ln -sf /usr/lib/amd64/VBoxOGL.so /usr/X11/lib/mesa/amd64/libGL.so.1
378 fi
379fi
380
381# Finalize
382/usr/sbin/removef -f $PKGINST
383/usr/sbin/installf -f $PKGINST
384
385
386if test "$currentzone" = "global"; then
387 # Setup our VBoxService SMF service
388 echo "Configuring service..."
389
390 /usr/sbin/svccfg import /var/svc/manifest/system/virtualbox/vboxservice.xml
391 /usr/sbin/svcadm enable svc:/system/virtualbox/vboxservice
392
393 /usr/sbin/devfsadm -i vboxguest
394
395 # Update boot archive
396 BOOTADMBIN=/sbin/bootadm
397 if test -x "$BOOTADMBIN"; then
398 if test -h "/dev/vboxguest"; then
399 echo "Updating boot archive..."
400 $BOOTADMBIN update-archive > /dev/null
401 else
402 echo "## Guest kernel module doesn't seem to be up. Skipped explicit boot-archive update."
403 fi
404 else
405 echo "## $BOOTADMBIN not found/executable. Skipped explicit boot-archive update."
406 fi
407fi
408
409
410echo "Done."
411if test $retval -eq 0; then
412 if test ! -z "$xorgbin"; then
413 echo "Please re-login to activate the X11 guest additions."
414 fi
415 echo "If you have just un-installed the previous guest additions a REBOOT is required."
416fi
417exit $retval
418
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