#!/bin/sh
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# Script for packaging Application Client Container
#

. %CONFIG_HOME%/asenv.conf

TEMP_DIR=$AS_INSTALL/lib/appclient
export TEMP_DIR

mkdir $TEMP_DIR/appclient
mkdir $TEMP_DIR/appclient/bin
mkdir $TEMP_DIR/appclient/config
mkdir $TEMP_DIR/appclient/lib
mkdir $TEMP_DIR/appclient/lib/dtds
mkdir $TEMP_DIR/appclient/lib/appclient
mkdir $TEMP_DIR/appclient/imq/
mkdir $TEMP_DIR/appclient/imq/lib

cp $AS_INSTALL/lib/install/templates/appclient.template $TEMP_DIR/appclient/bin/appclient
chmod 755 $TEMP_DIR/appclient/bin/appclient
cp $AS_INSTALL/lib/install/templates/asenv.conf.template $TEMP_DIR/appclient/config/asenv.conf
cp $AS_INSTALL/lib/dtds/sun-application-client-container_1_0.dtd $TEMP_DIR/appclient/lib/dtds/.
cp $AS_INSTALL/lib/install/templates/sun-acc.xml.template $TEMP_DIR/appclient/config/sun-acc.xml

cp $AS_INSTALL/lib/appserv-rt.jar $TEMP_DIR/appclient/lib/.
cp $AS_INSTALL/lib/appserv-ext.jar $TEMP_DIR/appclient/lib/.
cp $AS_INSTALL/lib/appserv-cmp.jar $TEMP_DIR/appclient/lib/.
cp $AS_INSTALL/lib/appserv-admin.jar $TEMP_DIR/appclient/lib/.

cp $AS_WEBSERVICES_LIB/activation.jar $TEMP_DIR/appclient/lib/.
cp $AS_WEBSERVICES_LIB/mail.jar $TEMP_DIR/appclient/lib/.

cp $AS_IMQ_LIB/imq.jar $TEMP_DIR/appclient/imq/lib/.
cp $AS_IMQ_LIB/imqadmin.jar $TEMP_DIR/appclient/imq/lib/.
cp $AS_IMQ_LIB/imqutil.jar $TEMP_DIR/appclient/imq/lib/.
cp $AS_IMQ_LIB/fscontext.jar $TEMP_DIR/appclient/imq/lib/.

cp $AS_INSTALL/lib/libcis.so $TEMP_DIR/appclient/lib/.

AS_NSS1=`echo $AS_NSS | awk -F":" '{print $1}'`
AS_NSS2=`echo $AS_NSS | awk -F":" '{print $2}'`

if [ -f $AS_NSS1/libssl3.so ] ; then
   cp $AS_NSS1/libssl3.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS1/libnss3.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS1/libplds4.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS1/libplc4.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS1/libnspr4.so $TEMP_DIR/appclient/lib/.
else
   cp $AS_NSS2/libssl3.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS2/libnss3.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS2/libplds4.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS2/libplc4.so $TEMP_DIR/appclient/lib/.
   cp $AS_NSS2/libnspr4.so $TEMP_DIR/appclient/lib/.
fi

cp $AS_INSTALL/lib/appclient/client.policy $TEMP_DIR/appclient/lib/appclient/.
cp $AS_INSTALL/lib/appclient/appclientlogin.conf $TEMP_DIR/appclient/lib/appclient/.

cd $TEMP_DIR
PATH=$AS_JAVA/bin:$PATH
export PATH
jar cvfM $AS_INSTALL/lib/appclient/appclient.jar appclient
rm -rf $TEMP_DIR/appclient
 
