# @(#)setkitvars	1.14	LPS_UNX_COM	2/19/95
#
# Copyright 1994   Digital Equipment Corporation, Maynard, MA
#
# setkitvars
#
# Shell script used to define all kit variables, common and platform specific.
#
#  Input:
#	This script requires that the caller set "KITCLASS" to the
#	proper kit designation strings.  The theory here is that this
#	script will setup all variables for a generic platform.  If
#	the file "setvars.$KITCLASS" exists then that script will be
#	"sourced", thus giving it the final say on all variable
#	definitions.
#
# This script is designed for use ONLY by the lpsinstall and lpssetup
# scripts.  This script is designed to be *imported* (via the Bourne
# shell "." command) and NOT directly executed in a subprocess.
#
# NOTE:	This script must execute with the current working directory being
#	either the root of the installation directory (LPSROOT), or the
#	root of the tree into which the kit was loaded from the distribution
#	media (LPSKIT).
#
# All variables defined in this script are also exported for use by any
# subsequent subprocess.  Note that this script has a VERY TIGHT BINDING
# with the "expkitvars" shell script, so changes made in this script
# should be propagated in the "expkitvars" shell script as well.
#
# This script expects that the "expkitvars" function is already loaded
# into the current shell environment (via the "lpssfuncs" script file).
#
# Global variables required to be set beforehand:
#
#    ABORT
#
# Any error conditions detected result in the evaluation of the $ABORT
# shell variable.
#
###

# Variables needed only by this script

cwd="`pwd`"

# Define (or redefine) all platform-INDEPENDENT variables.

CUTSTART="---------------literal text follows this line---------------"
CUTEND="--------------------end of literal text---------------------"
FUNCS="$cwd/scripts/lpsshfuncs"
INSTFLAG=".LPSinstalled"

# Define all platform-INDEPENDENT variables that are not already defined.
# Note that some of these are dependent upon the whether the value of the
# LPSDEBUG variable produces a non-null string.

: ${HELP:="true"}
: ${TMPDIR:="/tmp"}

: ${PAGER:="more"}

if [ `basename $PAGER` = "less" ]
then
    PAGER=more		# The "less" utility doesn't work very well here
fi


: ${KITINFO:="KITINFO"}
: ${LPSODB:="/etc/lpsodb"}
: ${LPSODBLIST:="lpsodblist"}

if [ "$LPSDEBUG" ]
then
    : ${LINKCHECKOPTS:="-d"}
else
    : ${LINKCHECKOPTS:=""}
fi

# Define (or redefine) all platform-SPECIFIC variables that are automatically
# and consistently derived indpendently of the platform type.
# Read in the KITINFO file to set critical top-level kit-SPECIFIC variables

if . ./$KITINFO
then
    :
else
    $ABORT
fi

# Now define all remaining platform-SPECIFIC variables based on the caller
# set value of the KITCLASS variable.  These are grabbed from the script file
# setvars.$KITCLASS.  If no such file exists, then we attempt to use the
# generic version of the file, if that exists.

if [ -f scripts/setvars.$KITCLASS ]
then
    varsfile=scripts/setvars.$KITCLASS
else
    varsfile=scripts/setvars.XXX
fi

if . $varsfile
then
    :    
else
    echo
    echo "    Unable to set kit variables from file: $varsfile"
    echo
    if [ ! -f scripts/setvars.$KITCLASS ]
    then
	echo "    Missing kit variables file setvars.$KITCLASS ???"
	echo
    fi
    $ABORT
fi

unset varsfile

# Set the local internet hostname for expediency and reuse

LOCALHOST="`hostname`"

# Now that the kit-specific things have been done, set the path
# so that the scripts subdirectory is searched first

PATH="$cwd/scripts:/bin:/usr/bin:/usr/lib:$PATH"

# Set and export several boolean environment variables that allow for
# rapid identification of kit capabilities.  These are used mostly by
# the lpsinitodb script.

if [ "`expr $KITTYPE : '.*BIN'`" != "0" ]   # Binary or Source kit?
then
    BINKIT=true
    SRCKIT=false
else
    BINKIT=false
    SRCKIT=true
fi

if [ "`expr $KITTYPE : '.*SH'`" != "0" ]  # Supporting Host facilities?
then
    SHKIT=true
else
    SHKIT=false
fi

if [ "`expr $KITTYPE : '.*PC'`" != "0" ]  # Print Client facilities?
then
    PCKIT=true
else
    PCKIT=false
fi

# Modify the PRODUCT variable to include the LPS software version

PRODUCT="${PRODUCT}, V${VERSION}"

# All variables have been defined, so ensure the whole lot is exported

expkitvars

# Undefine any local variables defined in this script so our environment
# doesn't get too large (particularly for Intel 386 platforms).

unset cwd
