#!/bin/sh -

# what_is is a script intended to achieve the followings:
#
# [1] setup up right environments in two enstore product configurations,
#     one, the original, with enstore core only and the other, the new
#     one, with most of supporting products included.
# [2] To work around the difficiency in UPS 4, in which there is not
#     flow control, which, as mentioned in the UPS manual, is under
#     consideration for future implementation.
#
# Historical background:
#
# enstore depend on several supporting products. At this file's creation
# time, enstore developers thought it was a good idea to roll some of
# the supporting products, of which enstore is the only user, into
# enstore itself to easy up the maintenance and release themselves from
# the responsibility of general support to those products.
#
# The new configuration is created using a meta-module in cvs. This
# meta-module is composed of core enstore and those supporting modules.
# It is conceivable that sometimes the developers need to checkout the
# core module only. Both configurations are supported and backward
# compatibility must be taken care of.
#
# In two enstore product configurations, the issue is how to setup up
# the supporting products, such as libtppy, HTMLgen, gadfly ... etc.
# The thought here is to have the setup script look for the supporting
# product subdirectories in enstore. If they exist, use them; otherwise,
# use the ones in UPS product area. Unfortunately, at this moment, UPS
# does not provide any flow control. Such heuristic can only implemented
# in shell escape script.
#
# Intuitively, there is one shell script file for each supporting
# products. To avoid the maintenance nightmare, the author decided to
# put all sciprts in one file which takes an argument to recall one
# of its multiple personalities.
#
# This is only meant to be a work around for the time being ...
# It should be replaced when there is a better solution, either a UPS
# with flow control or a new definition in policy ...
#

# ENSTORE_DIR must have been set by now
# find setups.sh
setups=/usr/local/etc/setups.sh
if [ ! -f $setups ] ; then quit "$setup not found" -4; fi
. $setups

case $1 in
	HTMLgen)
		if [ -d ${ENSTORE_DIR}/HTMLgen ]
		then
			echo ${ENSTORE_DIR}/HTMLgen
		else
			setup HTMLgen
			echo ${HTMLGEN_DIR}
		fi
	;;
	gadfly)
		if [ -d ${ENSTORE_DIR}/gadfly ]
		then
			echo ${ENSTORE_DIR}/gadfly
		else
			setup gadfly
			echo ${GADFLY_DIR}
		fi
	;;
	*)
		echo Do not understand $1
	;;
esac
