VirtualBox

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

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

Additions/Solaris: addressed locale breakage in a better way.

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