VirtualBox

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

Last change on this file since 39239 was 39239, checked in by vboxsync, 13 years ago

Additions/solaris: Turns out we don't need to do version specific hacks, remove unused code.

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