1 | #!/bin/sh
|
---|
2 | # $Id: postinstall.sh 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # VirtualBox postinstall script for Solaris Guest Additions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008-2020 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...
|
---|
29 | LC_ALL=C
|
---|
30 | export LC_ALL
|
---|
31 |
|
---|
32 | LANG=C
|
---|
33 | export LANG
|
---|
34 |
|
---|
35 | # uncompress(directory, file)
|
---|
36 | # Updates package metadata and uncompresses the file.
|
---|
37 | uncompress_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)
|
---|
55 | uncompress_files()
|
---|
56 | {
|
---|
57 | for i in "${1}/"*.Z; do
|
---|
58 | uncompress_file "${1}" "`basename \"${i}\" .Z`"
|
---|
59 | done
|
---|
60 | }
|
---|
61 |
|
---|
62 | solaris64dir="amd64"
|
---|
63 | solaris32dir="i386"
|
---|
64 | vboxadditions_path="$BASEDIR/opt/VirtualBoxAdditions"
|
---|
65 | vboxadditions32_path=$vboxadditions_path/$solaris32dir
|
---|
66 | vboxadditions64_path=$vboxadditions_path/$solaris64dir
|
---|
67 |
|
---|
68 | # get the current zone
|
---|
69 | currentzone=`zonename`
|
---|
70 | # get what ISA the guest is running
|
---|
71 | cputype=`isainfo -k`
|
---|
72 | if test "$cputype" = "amd64"; then
|
---|
73 | isadir=$solaris64dir
|
---|
74 | else
|
---|
75 | isadir=""
|
---|
76 | fi
|
---|
77 |
|
---|
78 | vboxadditionsisa_path=$vboxadditions_path/$isadir
|
---|
79 |
|
---|
80 |
|
---|
81 | # uncompress if necessary
|
---|
82 | if 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
|
---|
90 | fi
|
---|
91 |
|
---|
92 |
|
---|
93 | if 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 modules (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
|
---|
106 | fi
|
---|
107 |
|
---|
108 |
|
---|
109 | # check if X.Org exists (snv_130 and higher have /usr/X11/* as /usr/*)
|
---|
110 | if test -f "/usr/bin/Xorg"; then
|
---|
111 | xorgbin="/usr/bin/Xorg"
|
---|
112 | elif test -f "/usr/X11/bin/Xorg"; then
|
---|
113 | xorgbin="/usr/X11/bin/Xorg"
|
---|
114 | else
|
---|
115 | xorgbin=""
|
---|
116 | retval=0
|
---|
117 | fi
|
---|
118 |
|
---|
119 | # create links
|
---|
120 | echo "Creating links..."
|
---|
121 | if 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
|
---|
124 | fi
|
---|
125 |
|
---|
126 | # Install Xorg components to the required places
|
---|
127 | if 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 | # Xorg 1.19 and later already contain a driver for vboxvideo.
|
---|
162 | echo "As of X.Org Server 1.19, the VirtualBox graphics driver (vboxvideo) is part"
|
---|
163 | echo "of Solaris. Please install it from the package repository if necessary."
|
---|
164 | else
|
---|
165 | echo "Installing video driver for X.Org $xorgversion..."
|
---|
166 |
|
---|
167 | # Determine destination paths (snv_130 and above use "/usr/lib/xorg", older use "/usr/X11/lib"
|
---|
168 | vboxvideo32_dest_base="/usr/lib/xorg/modules/drivers"
|
---|
169 | if test ! -d $vboxvideo32_dest_base; then
|
---|
170 | vboxvideo32_dest_base="/usr/X11/lib/modules/drivers"
|
---|
171 | fi
|
---|
172 |
|
---|
173 | vboxvideo64_dest_base=$vboxvideo32_dest_base/$solaris64dir
|
---|
174 |
|
---|
175 | # snv_163 drops 32-bit support completely, and uses 32-bit locations for the 64-bit stuff. Ugly.
|
---|
176 | # We try to detect this by looking at bitness of "vesa_drv.so", and adjust our destination paths accordingly.
|
---|
177 | # We do not rely on using Xorg -version's ABI output because some builds (snv_162 iirc) have 64-bit ABI with
|
---|
178 | # 32-bit file locations.
|
---|
179 | if test -f "$vboxvideo32_dest_base/vesa_drv.so"; then
|
---|
180 | bitsize=`file "$vboxvideo32_dest_base/vesa_drv.so" | grep -i "32-bit"`
|
---|
181 | skip32="no"
|
---|
182 | else
|
---|
183 | echo "* Warning vesa_drv.so missing. Assuming Xorg ABI is 64-bit..."
|
---|
184 | fi
|
---|
185 |
|
---|
186 | if test -z "$bitsize"; then
|
---|
187 | skip32="yes"
|
---|
188 | vboxvideo64_dest_base=$vboxvideo32_dest_base
|
---|
189 | fi
|
---|
190 |
|
---|
191 | # Make sure destination path exists
|
---|
192 | if test ! -d $vboxvideo64_dest_base; then
|
---|
193 | echo "*** Missing destination paths for video module. Aborting."
|
---|
194 | echo "*** Failed to install the VirtualBox X Window System driver."
|
---|
195 |
|
---|
196 | # Exit as partially failed installation
|
---|
197 | retval=2
|
---|
198 | else
|
---|
199 | # 32-bit x11 drivers
|
---|
200 | if test "$skip32" = "no" && test -f "$vboxadditions32_path/$vboxvideo_src"; then
|
---|
201 | vboxvideo_dest="$vboxvideo32_dest_base/vboxvideo_drv.so"
|
---|
202 | /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
|
---|
203 | cp "$vboxadditions32_path/$vboxvideo_src" "$vboxvideo_dest"
|
---|
204 |
|
---|
205 | # Removing redundant names from pkg and files from disk
|
---|
206 | /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxvideo_drv_* 1>/dev/null
|
---|
207 | rm -f $vboxadditions32_path/vboxvideo_drv_*
|
---|
208 | fi
|
---|
209 |
|
---|
210 | # 64-bit x11 drivers
|
---|
211 | if test -f "$vboxadditions64_path/$vboxvideo_src"; then
|
---|
212 | vboxvideo_dest="$vboxvideo64_dest_base/vboxvideo_drv.so"
|
---|
213 | /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
|
---|
214 | cp "$vboxadditions64_path/$vboxvideo_src" "$vboxvideo_dest"
|
---|
215 |
|
---|
216 | # Removing redundant names from pkg and files from disk
|
---|
217 | /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxvideo_drv_* 1>/dev/null
|
---|
218 | rm -f $vboxadditions64_path/vboxvideo_drv_*
|
---|
219 | fi
|
---|
220 |
|
---|
221 | # Some distros like Indiana have no xorg.conf, deal with this
|
---|
222 | if test ! -f '/etc/X11/xorg.conf' && test ! -f '/etc/X11/.xorg.conf'; then
|
---|
223 |
|
---|
224 | # Xorg 1.3.x+ should use the modeline less Xorg confs while older should
|
---|
225 | # use ones with all the video modelines in place. Argh.
|
---|
226 | xorgconf_file="solaris_xorg_modeless.conf"
|
---|
227 | xorgconf_unfit="solaris_xorg.conf"
|
---|
228 | case "$xorgversion" in
|
---|
229 | 7.1.* | 7.2.* | 6.9.* | 7.0.* )
|
---|
230 | xorgconf_file="solaris_xorg.conf"
|
---|
231 | xorgconf_unfit="solaris_xorg_modeless.conf"
|
---|
232 | ;;
|
---|
233 | esac
|
---|
234 |
|
---|
235 | /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_file 1>/dev/null
|
---|
236 | mv -f $vboxadditions_path/$xorgconf_file /etc/X11/.xorg.conf
|
---|
237 |
|
---|
238 | /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_unfit 1>/dev/null
|
---|
239 | rm -f $vboxadditions_path/$xorgconf_unfit
|
---|
240 | fi
|
---|
241 |
|
---|
242 | # Check for VirtualBox graphics card
|
---|
243 | # S10u10's prtconf doesn't support the '-d' option, so let's use -v even though it's slower.
|
---|
244 | is_vboxgraphics=`prtconf -v | grep -i pci80ee,beef`
|
---|
245 | if test "$?" -eq 0; then
|
---|
246 | drivername="vboxvideo"
|
---|
247 | else
|
---|
248 | # Check for VMware graphics card
|
---|
249 | is_vmwaregraphics=`prtconf -v | grep -i pci15ad,405`
|
---|
250 | if test "$?" -eq 0; then
|
---|
251 | echo "Configuring X.Org to use VMware SVGA graphics driver..."
|
---|
252 | drivername="vmware"
|
---|
253 | fi
|
---|
254 | fi
|
---|
255 |
|
---|
256 | # Adjust xorg.conf with video driver sections if a supported graphics card is found
|
---|
257 | if test ! -z "$drivername"; then
|
---|
258 | $vboxadditions_path/x11config15sol.pl "$drivername"
|
---|
259 | else
|
---|
260 | # No supported graphics card found, do nothing.
|
---|
261 | echo "## No supported graphics card found. Skipped configuring of X.org drivers."
|
---|
262 | fi
|
---|
263 | fi
|
---|
264 | fi
|
---|
265 |
|
---|
266 |
|
---|
267 | # Setup our VBoxClient
|
---|
268 | echo "Configuring client..."
|
---|
269 | vboxclient_src=$vboxadditions_path
|
---|
270 | vboxclient_dest="/usr/share/gnome/autostart"
|
---|
271 | clientinstalled=0
|
---|
272 | if test -d "$vboxclient_dest"; then
|
---|
273 | /usr/sbin/installf -c none $PKGINST $vboxclient_dest/vboxclient.desktop=$vboxadditions_path/vboxclient.desktop s
|
---|
274 | clientinstalled=1
|
---|
275 | fi
|
---|
276 | vboxclient_dest="/usr/dt/config/Xsession.d"
|
---|
277 | if test -d "$vboxclient_dest"; then
|
---|
278 | /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
|
---|
279 | clientinstalled=1
|
---|
280 | fi
|
---|
281 |
|
---|
282 | # Try other autostart locations if none of the above ones work
|
---|
283 | if test $clientinstalled -eq 0; then
|
---|
284 | vboxclient_dest="/etc/xdg/autostart"
|
---|
285 | if test -d "$vboxclient_dest"; then
|
---|
286 | /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
|
---|
287 | clientinstalled=1
|
---|
288 | else
|
---|
289 | echo "*** Failed to configure client, couldn't find any autostart directory!"
|
---|
290 | # Exit as partially failed installation
|
---|
291 | retval=2
|
---|
292 | fi
|
---|
293 | fi
|
---|
294 | else
|
---|
295 | echo "(*) X.Org not found, skipped configuring X.Org guest additions."
|
---|
296 | fi
|
---|
297 |
|
---|
298 |
|
---|
299 | # Shared Folder kernel module (different for S10 & Nevada)
|
---|
300 | osverstr=`uname -r`
|
---|
301 | vboxfsmod="vboxfs"
|
---|
302 | vboxfsunused="vboxfs_s10"
|
---|
303 | if test "$osverstr" = "5.10"; then
|
---|
304 | vboxfsmod="vboxfs_s10"
|
---|
305 | vboxfsunused="vboxfs"
|
---|
306 | fi
|
---|
307 |
|
---|
308 | # Move the appropriate module to kernel/fs & remove the unused module name from pkg and file from disk
|
---|
309 | # 64-bit shared folder module
|
---|
310 | if test -f "$vboxadditions64_path/$vboxfsmod"; then
|
---|
311 | echo "Installing 64-bit shared folders module..."
|
---|
312 | /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/$solaris64dir/vboxfs" f
|
---|
313 | mv -f $vboxadditions64_path/$vboxfsmod /usr/kernel/fs/$solaris64dir/vboxfs
|
---|
314 | /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsmod 1>/dev/null
|
---|
315 | /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsunused 1>/dev/null
|
---|
316 | rm -f $vboxadditions64_path/$vboxfsunused
|
---|
317 | fi
|
---|
318 |
|
---|
319 | # 32-bit shared folder module
|
---|
320 | if test -f "$vboxadditions32_path/$vboxfsmod"; then
|
---|
321 | echo "Installing 32-bit shared folders module..."
|
---|
322 | /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/vboxfs" f
|
---|
323 | mv -f $vboxadditions32_path/$vboxfsmod /usr/kernel/fs/vboxfs
|
---|
324 | /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsmod 1>/dev/null
|
---|
325 | /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsunused 1>/dev/null
|
---|
326 | rm -f $vboxadditions32_path/$vboxfsunused
|
---|
327 | fi
|
---|
328 |
|
---|
329 | # Add a group "vboxsf" for Shared Folders access
|
---|
330 | # All users which want to access the auto-mounted Shared Folders have to
|
---|
331 | # be added to this group.
|
---|
332 | groupadd vboxsf >/dev/null 2>&1
|
---|
333 |
|
---|
334 | # Move the pointer integration module to kernel/drv & remove the unused module name from pkg and file from disk
|
---|
335 |
|
---|
336 | # Finalize
|
---|
337 | /usr/sbin/removef -f $PKGINST
|
---|
338 | /usr/sbin/installf -f $PKGINST
|
---|
339 |
|
---|
340 |
|
---|
341 | if test "$currentzone" = "global"; then
|
---|
342 | /usr/sbin/devfsadm -i vboxguest
|
---|
343 |
|
---|
344 | # Setup VBoxService and vboxmslnk and start the services automatically
|
---|
345 | echo "Configuring services (this might take a while)..."
|
---|
346 | cmax=32
|
---|
347 | cslept=0
|
---|
348 | success=0
|
---|
349 | sync
|
---|
350 |
|
---|
351 | # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
|
---|
352 | # take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
|
---|
353 | # 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
|
---|
354 | /usr/sbin/svcadm restart svc:system/manifest-import:default
|
---|
355 | /usr/bin/svcs virtualbox/vboxservice virtualbox/vboxmslnk >/dev/null 2>&1
|
---|
356 | while test "$?" -ne 0;
|
---|
357 | do
|
---|
358 | sleep 1
|
---|
359 | cslept=`expr $cslept + 1`
|
---|
360 | if test "$cslept" -eq "$cmax"; then
|
---|
361 | success=1
|
---|
362 | break
|
---|
363 | fi
|
---|
364 | /usr/bin/svcs virtualbox/vboxservice virtualbox/vboxmslnk >/dev/null 2>&1
|
---|
365 | done
|
---|
366 | if test "$success" -eq 0; then
|
---|
367 | echo "Enabling services..."
|
---|
368 | /usr/sbin/svcadm enable -s virtualbox/vboxservice
|
---|
369 | /usr/sbin/svcadm enable -s virtualbox/vboxmslnk
|
---|
370 | else
|
---|
371 | echo "## Service import failed."
|
---|
372 | echo "## See /var/svc/log/system-manifest-import:default.log for details."
|
---|
373 | # Exit as partially failed installation
|
---|
374 | retval=2
|
---|
375 | fi
|
---|
376 |
|
---|
377 | # Update boot archive
|
---|
378 | BOOTADMBIN=/sbin/bootadm
|
---|
379 | if test -x "$BOOTADMBIN"; then
|
---|
380 | if test -h "/dev/vboxguest"; then
|
---|
381 | echo "Updating boot archive..."
|
---|
382 | $BOOTADMBIN update-archive > /dev/null
|
---|
383 | else
|
---|
384 | echo "## Guest kernel module doesn't seem to be up. Skipped explicit boot-archive update."
|
---|
385 | fi
|
---|
386 | else
|
---|
387 | echo "## $BOOTADMBIN not found/executable. Skipped explicit boot-archive update."
|
---|
388 | fi
|
---|
389 | fi
|
---|
390 |
|
---|
391 | echo "Done."
|
---|
392 | if test $retval -eq 0; then
|
---|
393 | if test ! -z "$xorgbin"; then
|
---|
394 | echo "Please re-login to activate the X11 guest additions."
|
---|
395 | fi
|
---|
396 | echo "If you have just un-installed the previous guest additions a REBOOT is required."
|
---|
397 | fi
|
---|
398 | exit $retval
|
---|
399 |
|
---|