VirtualBox

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

Last change on this file since 53428 was 50659, checked in by vboxsync, 11 years ago

Additions/solaris: Fix trunk regression introduced in r92084.

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