#!/bin/ksh -p
#
# ident "@(#)utX11compatlinksctl.ksh	1.6 10/01/19 SMI"
#
# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

set -u

########################################################################
#
# Creates compatibility files and links under /etc/opt/SUNWut/X11
# 
#
# Creates the fontpath file under /opt/SUNWut/lib/X11.  It will first
# check the existance of the /etc/X11/fontpath.d directory on the server.
# If it exists, it will just create fontpath file with the "catalogue"
# entry for the fontpath.d directory.
#
########################################################################


########################################################################
#
# Operation entry points, one for each keyword.
# This is where the specific work for this feature happens.
#
########################################################################



removeFile() {
	typeset FILENAME=$1
	if [ -f $FILENAME ]; then
		rm -rf $FILENAME
		if $VERB; then
			print "$FILENAME file disabled"
		fi
	fi
	return 0
}

disable() {
	removeFile ${ETC_COMPATLINKS}/${FONTPATH_FILE}
}



enable_fontpath() {

	if [ -d ${FONTPATH_D} ]; then
		# create catalogue entry if fontpath.d directory exists.
		typeset TMPFILE=$SUNWUTVAR/tmp/${PROG}_catFile.$$
		print "catalogue:${FONTPATH_D}" > $TMPFILE
		mv -f $TMPFILE ${ETC_COMPATLINKS}/${FONTPATH_FILE}
		return $?
	fi

	return $?
}

enable() {
	enable_fontpath
	return $?
}


########################################################################
# Local Variables
# They must defined here to resolve the some of parameter resolution
# problem
########################################################################
local_variables() {
	ETC_COMPATLINKS=$SUNWUTETC/X11


	FONTPATH_FILE=fontpath
	FONTPATH_D=/etc/X11/fontpath.d
}


########################################################################
#
# Configurable parameter
#
########################################################################
# NONE


########################################################################
#
# Variables used in the shared script utctl-shlib
#
########################################################################
DESCR="Sets up X configuration for the Sun Ray Xserver program"


########################################################################
#
# Execution starts here
#
PROGPATH=`dirname $0`
. $PROGPATH/utctl-shlib
