VirtualBox

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

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

Additions/solaris/vboxms: adjust device name, vboxmouse to vboxms.

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

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