#!/bin/sh
## /public/scripts/pclcmistribute
## A Script to distribute compiled binaries and libraries to a WIN/NT LCM server.
## Globecom Classes files are copied into the /install/weblogic/classes.
## Also /usr/local/gwa bin and conf directories are created or updated.
## The file /install/weblogic/EJB_Param.ini is updated.
## The external and Admin jar files are copied.
## Two input parameters are required:
## 1. Build name
## 2. The release name
## 3. The installation package root directory
## 4. The drive where the software should be installed into.
## Last modified: 3.2.2002
if [ $# -lt 4 ]
then
echo ""
echo "Usage: $0 Build-name configuration-name installation-source-dir install-drive"
echo "Example: $0 Build3.0.0_9 prd_3.0.0 /cygdrive/e/prd_3.0.0/ins c"
echo ""
exit 1
fi
BUILDNAME=$1
CNFNAME=$2
CNFN=`echo $CNFNAME | awk -F. '{print $1}'`
INSDIR=$3
if [ ! -d $INSDIR ]
then
echo ""
echo $INSDIR" is not exist. Exit..."
echo ""
exit 1
fi
VERDIR=`dirname $INSDIR`
WINDRIVE=$4
INSDRIVE="/cygdrive/"$WINDRIVE
if [ ! -d $INSDRIVE ]
then
echo ""
echo $INSDRIVE" is not exist. Exit..."
echo ""
exit 1
fi
## Host name compute
HST=`hostname`
DMN=`ipconfig | grep "DNS Suffix" | awk '{print $NF}'`
HOSTN=$HST"."$DMN
## Current date and time variable set
CURDATE=`date +%Y%m%d%H%M`
echo "Create Globecom software directories"
GWADIR=$INSDRIVE"/usr/local/gwa"
if [ -d $GWADIR ]
then
PREVGWA=$GWADIR"_"$CURDATE
mv $GWADIR $PREVGWA
echo ""
echo "Previous version of "$GWADIR" was saved as "$PREVGWA
echo ""
fi
rm -rf $GWADIR
mkdir -p $GWADIR
mkdir $GWADIR/bin $GWADIR/conf $GWADIR/logs $GWADIR/old_logs
[ ! -d $INSDRIVE/var ] && mkdir $INSDRIVE/var
[ ! -d $INSDRIVE/var/zax ] && mkdir $INSDRIVE/var/zax
[ ! -d $INSDRIVE/inetpub/ftproot/publisher ] && mkdir $INSDRIVE/inetpub/ftproot/publisher
[ ! -d $INSDRIVE/inetpub/ftproot/publisherlog ] && mkdir $INSDRIVE/inetpub/ftproot/publisherlog
# Determine system type
SYS=WIN
if test "$SYS" = "WIN"
then
echo 'Install on WIN system\n'
RELNAME=SUN-Rel-$1
else
echo "Unknown system to install Globecom server on.\n"
exit
fi
# Copy the executables to $GWADIR/bin
cd $GWADIR/bin
echo " Copying binaries ...."
cp $INSDIR/XmlConvertor.exe .
# Copy the configuration files to $GWADIR/conf
cd $GWADIR/conf
echo " Copying configuration files ...."
cp $INSDIR/conf/GLB/trace.conf ./trace.conf
# Copy the Dlls to system directory
echo " Copying Xerces dlls ...."
cd $SYSTEMROOT/system32
rm -f xerces*.dll
cp $INSDIR/CI/xerces*.dll .
## Copy the java classes and the deployment files into ~weblogic/classes
[ ! -d $INSDRIVE/weblogic/classes ] && mkdir $INSDRIVE/weblogic/classes
if [ "$CNFN" = "prd_2" ]
then
[ ! -d $INSDRIVE/weblogic/classes/globecom/deploy ] && mkdir $INSDRIVE/weblogic/classes/globecom/deploy
cd $INSDRIVE/weblogic/classes/globecom/deploy
rm -f *
cp -f $INSDIR/deploy/* $INSDRIVE/weblogic/classes/globecom/deploy
else
[ ! -d $INSDRIVE/weblogic/classes/deploy ] && mkdir $INSDRIVE/weblogic/classes/deploy
cd $INSDRIVE/weblogic/classes/deploy
rm -f *
cp -f $INSDIR/deploy/* $INSDRIVE/weblogic/classes/deploy
fi
# Copy the Java Jar files
JARSDIR=$INSDRIVE"/weblogic/classes/Jars"
if [ -d $JARSDIR ]
then
rm -f $INSDRIVE/weblogic/classes/Jars/*.jar
else
mkdir -p $JARSDIR
fi
cp -f $INSDIR/Java/Jars/* $INSDRIVE/weblogic/classes/Jars
# Handling EJB_Param.ini
echo " Update EJB_Param.ini ...."
EJBPFILE=$INSDRIVE/weblogic/EJB_Param.ini
if [ -f $EJBPFILE ]
then
PREVEJB=$EJBPFILE"_"$CURDATE
mv $EJBPFILE $PREVEJB
echo ""
echo "Previous version of EJB_Param.ini was saved as "$PREVEJB
echo ""
fi
cp $INSDIR/conf/GLB/EJB_Param.ini_standalone $EJBPFILE
sed 's/win-drive/'$WINDRIVE'/' $EJBPFILE > $EJBPFILE.$$
mv $EJBPFILE.$$ $EJBPFILE
sed 's/host-name/'$HST'/' $EJBPFILE > $EJBPFILE.$$
mv $EJBPFILE.$$ $EJBPFILE
HOSTIP=`ipconfig | grep "IP Address" | awk '{print $NF}'`
sed 's/host-ip/'$HOSTIP'/' $EJBPFILE > $EJBPFILE.$$
mv $EJBPFILE.$$ $EJBPFILE
# Create preview directory
echo "Create preview directory ...."
PREVIEWDIR=`grep SECURED_PATH $EJBPFILE | awk '{print $NF}' | awk -F: '{print "/cygdrive/"$1$2"preview"}'`
[ ! -d $PREVIEWDIR ] && mkdir -p $PREVIEWDIR
# Create LPTPP directory
echo "Create LPTPP directory ...."
LPTPPDIR=`grep LPTPP_FILES_PATH $EJBPFILE | awk '{print $NF}' | awk -F: '{print "/cygdrive/"$1$2}'`
[ ! -d $LPTPPDIR ] && mkdir -p $LPTPPDIR
# Create Logs directory
echo "Create Logs directory ...."
LOGSDIR=`grep "^LOGGER_DIRECTORY" $EJBPFILE | awk '{print $NF}' | awk -F: '{print "/cygdrive/"$1$2}'`
[ ! -d $LOGSDIR ] && mkdir -p $LOGSDIR
# Create old Logs directory
echo "Create old Logs directory ...."
OLDLOGSDIR=`grep "OLD_LOGGER_DIRECTORY" $EJBPFILE | awk '{print $NF}' | awk -F: '{print "/cygdrive/"$1$2}'`
[ ! -d $OLDLOGSDIR ] && mkdir -p $OLDLOGSDIR
# Handling weblogic.properties
echo " Update weblogic.properties ...."
WPFILE=$INSDRIVE/weblogic/weblogic.properties
if [ -f $WPFILE ]
then
PREVWP=$WPFILE"_"$CURDATE
mv $WPFILE $PREVWP
echo ""
echo "Previous version of weblogic.properties was saved as "$PREVWP
fi
cp $INSDIR/conf/GLB/weblogic.properties_standalone $WPFILE
sed 's/win-drive/'$WINDRIVE'/' $WPFILE > $WPFILE.$$
mv $WPFILE.$$ $WPFILE
sed 's/host-name/'$HST'/' $WPFILE > $WPFILE.$$
mv $WPFILE.$$ $WPFILE
sed 's/db-srvr/'$HST'/' $WPFILE > $WPFILE.$$
mv $WPFILE.$$ $WPFILE
sed 's/db-pw/informix/' $WPFILE > $WPFILE.$$
mv $WPFILE.$$ $WPFILE
# Create SDU directory
echo "Create SDU directory ...."
SDUDIR="/cygdrive/"$WINDRIVE"/sdu"
[ ! -d $SDUDIR ] && mkdir -p $SDUDIR
# Create SDU-misc directory
echo "Create SDU_misc directory ...."
SDUMISCDIR="/cygdrive/"$WINDRIVE"/sdu_misc"
[ ! -d $SDUMISCDIR ] && mkdir -p $SDUMISCDIR
# Handling startWebLogic.cmd
echo " Update startWebLogic.cmd ...."
SWLFILE=$INSDRIVE/weblogic/startWebLogic.cmd
if [ -f $SWLFILE ]
then
PREVSWL=$SWLFILE"_"$CURDATE
mv $SWLFILE $PREVSWL
echo ""
echo "Previous version of startWebLogic.cmd was saved as "$PREVSWL
fi
cp $INSDIR/conf/GLB/startWebLogic.cmd $SWLFILE
sed 's/win-drive/'$WINDRIVE'/' $SWLFILE > $SWLFILE.$$
mv $SWLFILE.$$ $SWLFILE
# Copying chmod.exe program
echo " Update chmod.exe ...."
CHMODFILE=$INSDRIVE/weblogic/chmod.exe
if [ ! -f $CHMODFILE ]
then
if [ -f $INSDIR/conf/GLB/chmod.exe ]
then
cp $INSDIR/conf/GLB/chmod.exe $CHMODFILE
fi
fi
# Copying license files
echo " Update weblogic rishuy files ...."
LICJFILE=$INSDRIVE/weblogic/license/WebLogicLicense.java
if [ -f $LICJFILE ]
then
mv $LICJFILE $LICJFILE"_"$CURDATE
fi
cp $INSDIR/conf/GLB/WebLogicLicense.java $LICJFILE
LICXFILE=$INSDRIVE/weblogic/license/WeblogicLicense.xml
if [ -f $LICXFILE ]
then
mv $LICXFILE $LICXFILE"_"$CURDATE
fi
cp $INSDIR/conf/GLB/WeblogicLicense.xml $LICXFILE
# Copy the images files
echo " Copying images files ...."
IMAGESDIR=$INSDRIVE/weblogic/images
if [ -d $IMAGESDIR ]
then
rm -f $IMAGESDIR/*
else
mkdir -p $IMAGESDIR
fi
cp -f $INSDIR/images/* $IMAGESDIR
# Copy the help files
echo " Copying help files ...."
HELPDIR=$INSDRIVE/weblogic/help
if [ -d $HELPDIR ]
then
rm -f $HELPDIR/*
else
mkdir -p $HELPDIR
fi
cp -f $INSDIR/help/* $HELPDIR
# Copy Admin and cancel html files
echo " Copying Admin.html and Cancel.html files ...."
HTMLDIR=$INSDRIVE/weblogic
rm -f $HTMLDIR/Admin.html $HTMLDIR/Cancel.html
cp -f $INSDIR/conf/GLB/Admin.html_standalone $HTMLDIR/Admin.html
cp -f $INSDIR/conf/GLB/Cancel.html $HTMLDIR
# Copy Database scripts files
echo " Copying Database scripts ...."
DBADIR=$INSDRIVE/MakeDB/Windows
rm -rf $DBADIR
mkdir -p $DBADIR
cp -f $INSDIR/MakeDB/Windows/* $DBADIR
# Copy public scripts files
echo " Copying public scripts ...."
SCRIPTSDIR=$INSDRIVE/scripts
rm -rf $SCRIPTSDIR
mkdir -p $SCRIPTSDIR
cp -f $VERDIR/scripts/* $SCRIPTSDIR
# Create log files directories
echo " Create log files directories...."
[ ! -d $INSDRIVE/weblogic/MgsLogFiles_new ] && mkdir $INSDRIVE/weblogic/MgsLogFiles_new
[ ! -d $INSDRIVE/weblogic/MgsLogFiles_old ] && mkdir $INSDRIVE/weblogic/MgsLogFiles_old
echo "---------------------------------------------------------------"
exit 0