VirtualBox

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

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

Additions/solaris: Don't need to use full FMRI while enabling/disabling VBoxService.

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