VirtualBox

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

最後變更 在這個檔案從39875是 39813,由 vboxsync 提交於 13 年 前

Additions/Solaris: fix X.org 1.3.0 with correct xorg.conf handling.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette