#!/bin/ksh
#
# This sh script generates the set_doc_envs.sh script in root of the DOC
# directory tree.
#
# This script must reside in the configuration sub-directory of the DOC 
# directory tree. 

if [ $# -eq 0 ]; then
   echo DOC services bin directory required.
   exit 1
fi

DOC_SERVICES_BIN_DIR=$1

script_path=`whence $0` >/dev/null 2>&1
script_home=`dirname $script_path`

DOC_DIR=`dirname $script_path`/..

echo \
"# This sh script must be sourced to define environment variables used by all" \
> $DOC_DIR/set_doc_envs.sh

echo "# other shell scripts which support the DOC package." \
>> $DOC_DIR/set_doc_envs.sh

echo "#" >> $DOC_DIR/set_doc_envs.sh

echo "# Source this script with the command \". set_doc_envs.sh\"" \
>> $DOC_DIR/set_doc_envs.sh

echo "#" >> $DOC_DIR/set_doc_envs.sh

echo "# This script was automatically generated by the DOC script" \
>> $DOC_DIR/set_doc_envs.sh

echo "# make_set_doc_envs.sh on "`date` >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo "unset DOC_DIR" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_DIR" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_DIR=$DOC_DIR" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo "unset DOC_SERVICES_BIN_DIR" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_SERVICES_BIN_DIR" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_SERVICES_BIN_DIR=$DOC_SERVICES_BIN_DIR" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo "unset DOC_BIN" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_BIN" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_BIN=$DOC_DIR/bin" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo "unset DOC_CONFIG" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_CONFIG" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_CONFIG=\$DOC_DIR/configuration" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

#
# mail.jar and activation.jar were added in support of Clean Submission.
#
echo "unset DOC_CLASSES" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_CLASSES" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_CLASSES=$DOC_DIR/java_class:$DOC_DIR/java_class/DOC.jar:$DOC_DIR/java_class/swingall.jar:$DOC_DIR/java_class/file_sel.zip:$DOC_DIR/java_class/mail.jar:$DOC_DIR/java_class/activation.jar" \
>> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

#
# Add mail host information.  In the future, this variable will be changable in RPS2
#
echo "unset DOC_MAIL_HOST" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_MAIL_HOST" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_MAIL_HOST=localhost" >> $DOC_DIR/set_doc_envs.sh

echo "unset DOC_ORBIXWEB" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_ORBIXWEB" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_ORBIXWEB=\$DOC_CONFIG/OrbixWeb" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo "unset DOC_JRE_HOME" >> $DOC_DIR/set_doc_envs.sh
echo "export DOC_JRE_HOME" >> $DOC_DIR/set_doc_envs.sh
echo "DOC_JRE_HOME=$DOC_DIR/jre" >> $DOC_DIR/set_doc_envs.sh

echo "" >>  $DOC_DIR/set_doc_envs.sh

echo ". \$DOC_ORBIXWEB/setenvs.sh" >> $DOC_DIR/set_doc_envs.sh
