postinstall.sh revision a2f6500ea77004e215d6fc8fcdab25b1d4d1ad3d
0N/A#!/bin/sh
0N/A#
0N/A# VirtualBox postinstall script for Solaris.
0N/A#
0N/A# Copyright (C) 2008-2010 Oracle Corporation
0N/A#
0N/A# This file is part of VirtualBox Open Source Edition (OSE), as
0N/A# available from http://www.virtualbox.org. This file is free software;
0N/A# you can redistribute it and/or modify it under the terms of the GNU
0N/A# General Public License (GPL) as published by the Free Software
0N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A#
0N/A# The contents of this file may alternatively be used under the terms
0N/A# of the Common Development and Distribution License Version 1.0
0N/A# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
0N/A# VirtualBox OSE distribution, in which case the provisions of the
0N/A# CDDL are applicable instead of those of the GPL.
0N/A#
0N/A# You may elect to license modified versions of this file under the
0N/A# terms and conditions of either the GPL or the CDDL or both.
0N/A#
0N/A
0N/A# LC_ALL should take precedence over LC_* and LANG but whatever...
0N/ALC_ALL=C
0N/Aexport LC_ALL
0N/A
30N/ALANG=C
89N/Aexport LANG
271N/A
0N/A# uncompress(directory, file)
0N/A# Updates package metadata and uncompresses the file.
0N/Auncompress_file()
0N/A{
0N/A if test -z "$1" || test -z "$2"; then
0N/A echo "missing argument to uncompress_file()"
0N/A return 1
0N/A fi
0N/A
0N/A # Remove compressed path from the pkg
30N/A /usr/sbin/removef $PKGINST "$1/$2.Z" 1>/dev/null
89N/A
271N/A # Add uncompressed path to the pkg
271N/A /usr/sbin/installf -c none $PKGINST "$1/$2" f
0N/A
0N/A # Uncompress the file (removes compressed file when done)
89N/A uncompress -f "$1/$2.Z" > /dev/null 2>&1
0N/A}
0N/A
0N/A# uncompress_files(directory_with_*.Z_files)
0N/Auncompress_files()
0N/A{
0N/A for i in "${1}/"*.Z; do
0N/A uncompress_file "${1}" "`basename \"${i}\" .Z`"
0N/A done
0N/A}
89N/A
0N/Asolaris64dir="amd64"
0N/Asolaris32dir="i386"
606N/Avboxadditions_path="$BASEDIR/opt/VirtualBoxAdditions"
606N/Avboxadditions32_path=$vboxadditions_path/$solaris32dir
332N/Avboxadditions64_path=$vboxadditions_path/$solaris64dir
332N/A
332N/A# get the current zone
332N/Acurrentzone=`zonename`
332N/A# get what ISA the guest is running
332N/Acputype=`isainfo -k`
332N/Aif test "$cputype" = "amd64"; then
332N/A isadir=$solaris64dir
332N/Aelse
332N/A isadir=""
332N/Afi
0N/A
0N/Avboxadditionsisa_path=$vboxadditions_path/$isadir
0N/A
0N/A
0N/A# uncompress if necessary
0N/Aif test -f "$vboxadditions32_path/VBoxClient.Z" || test -f "$vboxadditions64_path/VBoxClient.Z"; then
0N/A echo "Uncompressing files..."
0N/A if test -f "$vboxadditions32_path/VBoxClient.Z"; then
0N/A uncompress_files "$vboxadditions32_path"
0N/A fi
146N/A if test -f "$vboxadditions64_path/VBoxClient.Z"; then
0N/A uncompress_files "$vboxadditions64_path"
0N/A fi
0N/Afi
0N/A
146N/A
146N/Aif test "$currentzone" = "global"; then
146N/A # vboxguest.sh would've been installed, we just need to call it.
146N/A echo "Configuring VirtualBox guest kernel module..."
0N/A # stop all previous moduels (vboxguest, vboxfs) and start only starts vboxguest
0N/A $vboxadditions_path/vboxguest.sh stopall silentunload
0N/A $vboxadditions_path/vboxguest.sh start
0N/A
0N/A sed -e '/name=vboxguest/d' /etc/devlink.tab > /etc/devlink.vbox
0N/A echo "type=ddi_pseudo;name=vboxguest \D" >> /etc/devlink.vbox
0N/A mv -f /etc/devlink.vbox /etc/devlink.tab
0N/A
0N/A # create the device link
0N/A /usr/sbin/devfsadm -i vboxguest
0N/Afi
0N/A
0N/A
0N/A# check if X.Org exists (snv_130 and higher have /usr/X11/* as /usr/*)
0N/Aif test -f "/usr/bin/Xorg"; then
0N/A xorgbin="/usr/bin/Xorg"
146N/Aelif test -f "/usr/X11/bin/Xorg"; then
0N/A xorgbin="/usr/X11/bin/Xorg"
0N/Aelse
0N/A xorgbin=""
0N/A retval=0
0N/Afi
0N/A
0N/A# create links
0N/Aecho "Creating links..."
0N/Aif test "$currentzone" = "global"; then
0N/A /usr/sbin/installf -c none $PKGINST /dev/vboxguest=../devices/pci@0,0/pci80ee,cafe@4:vboxguest s
0N/A /usr/sbin/installf -c none $PKGINST /dev/vboxms=../devices/pseudo/vboxms@0:vboxms s
0N/Afi
0N/A
146N/A# Install Xorg components to the required places
146N/Aif test ! -z "$xorgbin"; then
146N/A xorgversion_long=`$xorgbin -version 2>&1 | grep "X Window System Version"`
146N/A xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X Window System Version \([^ ]*\)'`
146N/A if test -z "$xorgversion_long"; then
146N/A xorgversion_long=`$xorgbin -version 2>&1 | grep "X.Org X Server"`
146N/A xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X.Org X Server \([^ ]*\)'`
0N/A fi
606N/A
606N/A # "X.Y.Z" - strip off all numerics after the 2nd '.' character, e.g. "1.11.3" -> "1.11"
606N/A # Then the next sed, strips of all '.' characters, "1.11" -> "111".
606N/A fileversion=`echo $xorgversion | sed "s/\.[0-9]*//2" | sed "s/\.//"`
606N/A vboxvideo_src="vboxvideo_drv_$fileversion.so"
606N/A
606N/A # Handle exceptions now where the X.org version does not exactly match the file-version.
606N/A case "$xorgversion" in
0N/A 1.5.99 )
0N/A vboxvideo_src="vboxvideo_drv_16.so"
0N/A ;;
0N/A 7.2.* )
0N/A vboxvideo_src="vboxvideo_drv_71.so"
0N/A ;;
0N/A 6.9.* )
0N/A vboxvideo_src="vboxvideo_drv_70.so"
0N/A ;;
0N/A esac
0N/A
0N/A retval=0
0N/A if test -z "$vboxvideo_src"; then
0N/A echo "*** Unknown version of the X Window System installed."
0N/A echo "*** Failed to install the VirtualBox X Window System drivers."
0N/A
0N/A # Exit as partially failed installation
0N/A retval=2
0N/A elif test ! -f "$vboxadditions32_path/$vboxvideo_src" && test ! -f "$vboxadditions64_path/$vboxvideo_src"; then
0N/A echo "*** $vboxadditions32_path/$vboxvideo_src or $vboxadditions64_path/$vboxvideo_src not found!"
0N/A echo "*** Failed to install the VirtualBox X.org drivers."
0N/A
0N/A # Exit as partially failed installation
89N/A retval=2
0N/A else
0N/A echo "Installing video driver for X.Org $xorgversion..."
35N/A
# Determine destination paths (snv_130 and above use "/usr/lib/xorg", older use "/usr/X11/lib"
vboxvideo32_dest_base="/usr/lib/xorg/modules/drivers"
if test ! -d $vboxvideo32_dest_base; then
vboxvideo32_dest_base="/usr/X11/lib/modules/drivers"
fi
vboxvideo64_dest_base=$vboxvideo32_dest_base/$solaris64dir
# snv_163 drops 32-bit support completely, and uses 32-bit locations for the 64-bit stuff. Ugly.
# We try to detect this by looking at bitness of "vesa_drv.so", and adjust our destination paths accordingly.
# We do not rely on using Xorg -version's ABI output because some builds (snv_162 iirc) have 64-bit ABI with
# 32-bit file locations.
if test -f "$vboxvideo32_dest_base/vesa_drv.so"; then
bitsize=`file "$vboxvideo32_dest_base/vesa_drv.so" | grep -i "32-bit"`
skip32="no"
else
echo "* Warning vesa_drv.so missing. Assuming Xorg ABI is 64-bit..."
fi
if test -z "$bitsize"; then
skip32="yes"
vboxvideo64_dest_base=$vboxvideo32_dest_base
fi
# Make sure destination path exists
if test ! -d $vboxvideo64_dest_base; then
echo "*** Missing destination paths for video module. Aborting."
echo "*** Failed to install the VirtualBox X Window System driver."
# Exit as partially failed installation
retval=2
else
# 32-bit x11 drivers
if test "$skip32" = "no" && test -f "$vboxadditions32_path/$vboxvideo_src"; then
vboxvideo_dest="$vboxvideo32_dest_base/vboxvideo_drv.so"
/usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
cp "$vboxadditions32_path/$vboxvideo_src" "$vboxvideo_dest"
# Removing redundant names from pkg and files from disk
/usr/sbin/removef $PKGINST $vboxadditions32_path/vboxvideo_drv_* 1>/dev/null
rm -f $vboxadditions32_path/vboxvideo_drv_*
fi
# 64-bit x11 drivers
if test -f "$vboxadditions64_path/$vboxvideo_src"; then
vboxvideo_dest="$vboxvideo64_dest_base/vboxvideo_drv.so"
/usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
cp "$vboxadditions64_path/$vboxvideo_src" "$vboxvideo_dest"
# Removing redundant names from pkg and files from disk
/usr/sbin/removef $PKGINST $vboxadditions64_path/vboxvideo_drv_* 1>/dev/null
rm -f $vboxadditions64_path/vboxvideo_drv_*
fi
# Some distros like Indiana have no xorg.conf, deal with this
if test ! -f '/etc/X11/xorg.conf' && test ! -f '/etc/X11/.xorg.conf'; then
# Xorg 1.3.x+ should use the modeline less Xorg confs while older should
# use ones with all the video modelines in place. Argh.
xorgconf_file="solaris_xorg_modeless.conf"
xorgconf_unfit="solaris_xorg.conf"
case "$xorgversion" in
7.1.* | 7.2.* | 6.9.* | 7.0.* )
xorgconf_file="solaris_xorg.conf"
xorgconf_unfit="solaris_xorg_modeless.conf"
;;
esac
/usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_file 1>/dev/null
mv -f $vboxadditions_path/$xorgconf_file /etc/X11/.xorg.conf
/usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_unfit 1>/dev/null
rm -f $vboxadditions_path/$xorgconf_unfit
fi
# Adjust xorg.conf with video driver sections
$vboxadditions_path/x11config15sol.pl
fi
fi
# Setup our VBoxClient
echo "Configuring client..."
vboxclient_src=$vboxadditions_path
vboxclient_dest="/usr/share/gnome/autostart"
clientinstalled=0
if test -d "$vboxclient_dest"; then
/usr/sbin/installf -c none $PKGINST $vboxclient_dest/vboxclient.desktop=$vboxadditions_path/vboxclient.desktop s
clientinstalled=1
fi
vboxclient_dest="/usr/dt/config/Xsession.d"
if test -d "$vboxclient_dest"; then
/usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
clientinstalled=1
fi
# Try other autostart locations if none of the above ones work
if test $clientinstalled -eq 0; then
vboxclient_dest="/etc/xdg/autostart"
if test -d "$vboxclient_dest"; then
/usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
clientinstalled=1
else
echo "*** Failed to configure client, couldn't find any autostart directory!"
# Exit as partially failed installation
retval=2
fi
fi
else
echo "(*) X.Org not found, skipped configuring X.Org guest additions."
fi
# Shared Folder kernel module (different for S10 & Nevada)
osverstr=`uname -r`
vboxfsmod="vboxfs"
vboxfsunused="vboxfs_s10"
if test "$osverstr" = "5.10"; then
vboxfsmod="vboxfs_s10"
vboxfsunused="vboxfs"
fi
# Move the appropriate module to kernel/fs & remove the unused module name from pkg and file from disk
# 64-bit shared folder module
if test -f "$vboxadditions64_path/$vboxfsmod"; then
echo "Installing 64-bit shared folders module..."
/usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/$solaris64dir/vboxfs" f
mv -f $vboxadditions64_path/$vboxfsmod /usr/kernel/fs/$solaris64dir/vboxfs
/usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsmod 1>/dev/null
/usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsunused 1>/dev/null
rm -f $vboxadditions64_path/$vboxfsunused
fi
# 32-bit shared folder module
if test -f "$vboxadditions32_path/$vboxfsmod"; then
echo "Installing 32-bit shared folders module..."
/usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/vboxfs" f
mv -f $vboxadditions32_path/$vboxfsmod /usr/kernel/fs/vboxfs
/usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsmod 1>/dev/null
/usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsunused 1>/dev/null
rm -f $vboxadditions32_path/$vboxfsunused
fi
# Add a group "vboxsf" for Shared Folders access
# All users which want to access the auto-mounted Shared Folders have to
# be added to this group.
groupadd vboxsf >/dev/null 2>&1
# install openGL extensions for X.Org
if test ! -z "$xorgbin"; then
# 32-bit crogl opengl library replacement
if test -f "/usr/lib/VBoxOGL.so"; then
cp -f /usr/X11/lib/mesa/libGL.so.1 /usr/X11/lib/mesa/libGL_original_.so.1
ln -sf /usr/lib/VBoxOGL.so /usr/X11/lib/mesa/libGL.so.1
fi
# 64-bit crogl opengl library replacement
if test -f "/usr/lib/amd64/VBoxOGL.so"; then
cp -f /usr/X11/lib/mesa/amd64/libGL.so.1 /usr/X11/lib/mesa/amd64/libGL_original_.so.1
ln -sf /usr/lib/amd64/VBoxOGL.so /usr/X11/lib/mesa/amd64/libGL.so.1
fi
fi
# Move the pointer integration module to kernel/drv & remove the unused module name from pkg and file from disk
# Finalize
/usr/sbin/removef -f $PKGINST
/usr/sbin/installf -f $PKGINST
if test "$currentzone" = "global"; then
/usr/sbin/devfsadm -i vboxguest
# Setup VBoxService and vboxmslnk and start the services automatically
echo "Configuring services (this might take a while)..."
cmax=32
cslept=0
success=0
sync
# Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
# take a while to complete, using disable/enable -s doesn't work either. So we restart it, and poll in
# 1 second intervals to see if our service has been successfully imported and timeout after 'cmax' seconds.
/usr/sbin/svcadm restart svc:system/manifest-import:default
## @todo why do we redirect to /dev/null and then save the output?
is_import=`/usr/bin/svcs virtualbox/vboxservice >/dev/null 2>&1 && /usr/bin/svcs virtualbox/vboxmslnk >/dev/null 2>&1`
while test $? -ne 0;
do
sleep 1
cslept=`expr $cslept + 1`
if test "$cslept" -eq "$cmax"; then
success=1
break
fi
is_import=`/usr/bin/svcs virtualbox/vboxservice >/dev/null 2>&1 && /usr/bin/svcs virtualbox/vboxmslnk >/dev/null 2>&1`
done
if test "$success" -eq 0; then
echo "Enabling services..."
/usr/sbin/svcadm enable -s virtualbox/vboxservice
/usr/sbin/svcadm enable -s virtualbox/vboxmslnk
else
echo "## Service import failed."
echo "## See /var/svc/log/system-manifest-import:default.log for details."
# Exit as partially failed installation
retval=2
fi
# Update boot archive
BOOTADMBIN=/sbin/bootadm
if test -x "$BOOTADMBIN"; then
if test -h "/dev/vboxguest"; then
echo "Updating boot archive..."
$BOOTADMBIN update-archive > /dev/null
else
echo "## Guest kernel module doesn't seem to be up. Skipped explicit boot-archive update."
fi
else
echo "## $BOOTADMBIN not found/executable. Skipped explicit boot-archive update."
fi
fi
echo "Done."
if test $retval -eq 0; then
if test ! -z "$xorgbin"; then
echo "Please re-login to activate the X11 guest additions."
fi
echo "If you have just un-installed the previous guest additions a REBOOT is required."
fi
exit $retval