#!/bin/sh
# $Id$
# *===========================================================================*
# |                 Copyright (c) 2008 Applaud Solutions UK Ltd               |
# |                             All rights reserved                           |
# *===========================================================================*

header_string="$Id$"
prog_version=`echo "$header_string" | awk '{print $3}'`
program=`basename $0 .sh`

usage="\t$program"

#
# Validate that APPL_TOP is set
#
$XXAS_LOG "Checking APPL_TOP is set..."
if test ! "$APPL_TOP" ; then
   printf "ERROR: The "\$"APPL_TOP environment variable is not set.\n"
   printf "Please log in to the APPL_TOP environment before running this install.\n\n"
   exit 1;
fi
$XXAS_LOG "ok"

#
# Validate that APPL_TOP is a valid directory
#
$XXAS_LOG "Checking the APPL_TOP directory exists..."
if test ! -d "$APPL_TOP" ; then
   printf "ERROR: The following "\$"APPL_TOP directory does not exist:\n"
   printf "$APPL_TOP\n"
   exit 1;
fi
$XXAS_LOG "ok"

#
# Validate write permissions to APPL_TOP
#
$XXAS_LOG "Checking write permissions to APPL_TOP directory..."
if test ! -w "$APPL_TOP" ; then
   printf "ERROR: You do not have write permissions to the "\$"APPL_TOP directory.\n\n"
   exit 1;
fi
$XXAS_LOG "ok"

#
# Set and export environment variables
#
XXAS_APPS_LOGIN=$XXAS_APPS_UN/$XXAS_APPS_PW; export XXAS_APPS_LOGIN
XXAS_PATCH_PROD=$XXAS_PATCH_TOP/XXAS_TOP; export XXAS_PATCH_PROD
XXAS_PATCH_BIN=$XXAS_PATCH_PROD/bin; export XXAS_PATCH_BIN
XXAS_PATCH_SQL=$XXAS_PATCH_PROD/sql; export XXAS_PATCH_SQL
XXAS_PATCH_IMPORT=$XXAS_PATCH_PROD/import; export XXAS_PATCH_IMPORT
XXAS_PATCH_METADATA=$XXAS_PATCH_TOP/metadata; export XXAS_PATCH_METADATA
XXAS_TOP=$APPL_TOP/xxas/1.0.1; export XXAS_TOP
XXAS_PROD_TOP=$XXAS_TOP; export XXAS_PROD_TOP
XXAS_PROD_BIN=$XXAS_PROD_TOP/bin; export XXAS_PROD_BIN
XXAS_PROD_SQL=$XXAS_PROD_TOP/sql; export XXAS_PROD_SQL
XXAS_PROD_IMPORT=$XXAS_PROD_TOP/import; export XXAS_PROD_IMPORT
XXAS_SQLPLUS=$ORACLE_HOME/bin/sqlplus; export XXAS_SQLPLUS
XXAS_FNDLOAD=$FND_TOP/bin/FNDLOAD; export XXAS_FNDLOAD
XXAS_WFLOAD=$FND_TOP/bin/WFLOAD; export XXAS_WFLOAD
HOST_NAME=`hostname|awk -F. '{print $1}'`; export HOST_NAME

#
# Set IFS to just a new line to avoid delimiting by space
#
IFS="
"
export IFS

$XXAS_LOG "Setting additional environment variables:"
$XXAS_LOG "Product Top:     $XXAS_TOP"
$XXAS_LOG "SQLPlus:         $XXAS_SQLPLUS"
$XXAS_LOG "FNDLOAD:         $XXAS_FNDLOAD"

