#
# ident "@(#)postinstall.src	1.7    08/09/04 SMI"
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# This script is to be run on linux only. It updates
# /opt/SUNWut/lib/xkb with a link to the xkbcomp command.

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/lib/X11/xkb
if [ -d /usr/X11R6/lib/X11/xkb ]; then
	XKBDIR=/usr/X11R6/lib/X11/xkb
elif [ -d /usr/share/X11/xkb ]; then
	XKBDIR=/usr/share/X11/xkb
else 
	print -u2 "xkb directory not found"
	exit 1
fi

if [ -z "$BASEDIR" ]; then BASEDIR="/opt"; fi

LIBDIR=$BASEDIR/SUNWut/lib

UTDSTXKBDIR=$LIBDIR/xkb

cd $UTDSTXKBDIR

# make sure that compiled link exists
if [ ! -e $UTDSTXKBDIR/compiled ]; then
    if [ -d /var/lib/xkb ]; then
	ln -s /var/lib/xkb $UTDSTXKBDIR/compiled
    else
	# this cannot not happen since SUNWuto will create the directory if it 
	# does not already exist unless instalation failed.
	echo "**Missing /var/lib/xkb directory.  This could be an installation"
	echo "problem.  This is required in order for Sun Ray Xnewt to support"
	echo "the XKB extension."
    fi
fi

# make sure that the xkbcomp exists
if [ ! -e $UTDSTXKBDIR/xkbcomp ]; then
    # on SLES, it's located under the $XKBDIR.
    # on RH, xkbcomp is located under /usr/bin rather than the default $XKBDIR.
    for xdir in $XKBDIR /usr/bin
    do
    	if [ -x $xdir/xkbcomp ]; then
	    ln -s $xdir/xkbcomp $UTDSTXKBDIR/xkbcomp
	    break
	fi
    done
    if [ ! -L $UTDSTXKBDIR/xkbcomp ]; then
	# this error will cause the xkb to fail
	echo "**Cannot locate xkbcomp utility on your system.  This is required in"
	echo "order to enable XKB support.  Please find the xkbcomp utility on your"
	echo "system and create a symbolic under $UTDSTXKBDIR."
    fi
fi
exit 0
