#! /bin/sh
#
# @(#)lpsmxxinit	1.3	LPS_UNX_COM	02/19/95
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# lpsmxxinit
#
# Imported shell script to initialize a top-level management script
# (one of the "lpsmxx" scripts: "lpsmpc", "lpsmmc and "lpsmps").
# This script performs the following common initialization tasks:
#
#    o  Clear the screen
#    o  Display the "intro" text using the prescribed "pager" utility
#    o  Verify the script is running under the lpssetup script
#    o  Load the common shell functions library
#    o  Export all common kit variables
#    o  Setup a signal trap for script abort conditions
#    o  Fetch the current Environment variables and export them
#
# To perform these tasks, the following shell variables must already
# be defined within the process:
#    ATTRLIST
#    ECHON
#    FUNCS
#    INTROTEXT
#    LPSSETUP
#    PSPID
#    SCRIPTNAME
#    TMPDIR
#
# NOTE:  This script must be imported into the current process
#	 using the Bourne shell "." command.
###

#----------------------------------------------------------------------

# Announce the purpose of this script

clear

$PAGER <<END_OF_INPUT
$INTROTEXT
END_OF_INPUT

#----------------------------------------------------------------------

# Verify that we have been invoked by the "lpssetup" master shell script.

if [ "$LPSSETUP" ]
then
    if [ `$PSPID $LPSSETUP | wc -l` = 2 ]
    then
	:
    else
	LPSSETUP=""
    fi
fi

if [ -z "$LPSSETUP" ]
then
    echo
    echo '    This script can only be executed by the "lpssetup" script!'
    exit 1
fi

#----------------------------------------------------------------------

# Perform any other required integrity tests:
#
#    1) Ensure the critical variable list file exists
#

if [ ! -f $ATTRLIST ]
then
    echo
    echo "$SCRIPTNAME: The variable list file $ATTRLIST does not exist!"
    echo
    pause
    exit 1
fi

#----------------------------------------------------------------------

# Load the common LPS shell script functions.  The lpssetup script
# ensures that this file exists and is executable by this process.
# Also export all common kit variables now.

. $FUNCS

expkitvars

#----------------------------------------------------------------------

# Setup activities to be executed upon encountering certain signals.

trap 'echo ; \
      echo $SCRIPTNAME script terminating... ; \
      echo ; \
      rm -f $TMPDIR/*.$$ ; \
      rm -f /tmp/*.$$ ; \
      rm -f ./*.$$ ; \
      pause ; \
      exit 1' \
      1 2 3 15

#---------------------------------------------------------------------

# Import all Environment object attributes for our general use,
# and export them in case any subprocesses require them.

getobject false ENV

expobjvars ENV
