#!/bin/bash

# Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# IBM makes no representations or warranties about the suitability of
# this program, either express or implied, including but not limited to
# the implied warranties of merchantability, fitness for a particular
# purpose, or non-infringement. 
  


# Sachin Prasad
# Trigo Technologies

# usage: exportCompany --company_code=<code> --script_path=<path/to/trigo/script>

. ${TOP}/bin/get_params.sh

if [ -z ${_CCD_COMPANY_CODE} ]; then
    echo Company code not specified
    echo "usage: exportCompany --company_code=<code> --script_path=<path/to/trigo/script>"
    exit
fi

if [ -z ${_CCD_SCRIPT_PATH} ]; then
    echo Script Path not specified
    echo "usage: exportCompany --company_code=<code> --script_path=<path/to/trigo/script>"
    exit
fi

if [ ! -e ${_CCD_SCRIPT_PATH} ]; then
    echo "Script not found" 
    exit
fi

if [ -e ./exportCompany.log ]; then 
    echo "The log file for last exportCompany exists and will be overwritten. Continue (y/n)?"
   read res
   if [ "$res" = "n" ]; then
       echo "!! exiting"
       exit
   fi
fi

if [ -z "$EXPORT_MEM_FLAGS" ]; then
    export EXPORT_MEM_FLAGS="-Xmx1024m -Xms1024m"
fi

touch exportCompany.log
echo "============================================================"
$JAVA_RT ${EXPORT_MEM_FLAGS} com.ibm.ccd.envexpimp.common.EnvironmentExporter -companycode=${_CCD_COMPANY_CODE} -scriptpath=${_CCD_SCRIPT_PATH} | tee exportCompany.log
echo 
echo "+++The log file has been created at `pwd`/exportCompany.log"
echo "============================================================"

