Skip to content

Commit

Permalink
Merge pull request #35 from ntrip/bwce-tci-build-merge
Browse files Browse the repository at this point in the history
Updated the scripts to support BWCE-TCI runtime build merging
  • Loading branch information
VardhanaKulkarni authored Oct 21, 2019
2 parents b755704 + d17792b commit 8387170
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 48 deletions.
161 changes: 113 additions & 48 deletions reducedStartupTime/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
#
#Use this setup.sh script to unzip the bwce-runitme zip while creating the base image.

#Variables coming from TCI scripts
TCI_BW_EDITION=$1
TCI_HOME=$2
CLOUD_VERSION=$3
BWCE_HOME=$4

echo "INFO Variables received :" $TCI_BW_EDITION, $TCI_HOME, $CLOUD_VERSION, $BWCE_HOME

print_Debug()
{
if [[ ${BW_LOGLEVEL} && "${BW_LOGLEVEL,,}"="debug" ]]; then
echo $1
fi
}

extract ()
{
if [ -f $1 ] ; then
Expand Down Expand Up @@ -63,7 +72,7 @@ checkProfile()
for name in $(find $BUILD_DIR -path $BUILD_DIR/tibco.home -prune -o -type f -iname "*.jar");
do
if [[ $name == *.jar ]]; then
mkdir -p $BUILD_DIR/temp
mkdir -p $BUILD_DIR/temp
unzip -o -q $name -d $BUILD_DIR/temp
MANIFESTMF=$BUILD_DIR/temp/META-INF/MANIFEST.MF

Expand Down Expand Up @@ -95,8 +104,7 @@ checkProfile()
defaultProfile=$x;;esac
done

if [ -z ${BW_PROFILE:=${defaultProfile}} ]; then
echo "BW_PROFILE is unset. Set it to $defaultProfile";
if [ -z ${BW_PROFILE:=${defaultProfile}} ]; then echo "BW_PROFILE is unset. Set it to $defaultProfile";
else
case $BW_PROFILE in
*.substvar ) ;;
Expand Down Expand Up @@ -139,7 +147,6 @@ setLogLevel()
fi
}


checkEnvSubstituteConfig()
{
bwappnodeTRA=$BWCE_HOME/tibco.home/bw*/*/bin/bwappnode.tra
Expand All @@ -148,7 +155,7 @@ checkEnvSubstituteConfig()
manifest=/tmp/META-INF/MANIFEST.MF
bwAppNameHeader="Bundle-SymbolicName"
bwBundleAppName=`while read line; do printf "%q\n" "$line"; done<${manifest} | awk '/.*:/{printf "%s%s", (NR==1)?"":RS,$0;next}{printf "%s", FS $0}END{print ""}' | grep -o $bwAppNameHeader.* | cut -d ":" -f2 | tr -d '[[:space:]]' | sed "s/\\\\\r'//g" | sed "s/$'//g"`
export BWCE_APP_NAME=$bwBundleAppName
export BWCE_APP_NAME=$bwBundleAppName
if [ -e ${bwappnodeTRA} ]; then
sed -i 's?-Djava.class.path=?-Djava.class.path=$ADDONS_HOME/lib:?' $bwappnodeTRA
print_Debug "Appended ADDONS_HOME/lib in bwappnode.tra file"
Expand All @@ -157,6 +164,7 @@ checkEnvSubstituteConfig()
sed -i 's?-Djava.class.path=?-Djava.class.path=$ADDONS_HOME/lib:?' $bwappnodeFile
print_Debug "Appended ADDONS_HOME/lib in bwappnode file"
fi

if [[ ${BW_JAVA_OPTS} ]]; then
if [ -e ${bwappnodeTRA} ]; then
sed -i.bak "/java.extended.properties/s/$/ ${BW_JAVA_OPTS}/" $bwappnodeTRA
Expand Down Expand Up @@ -216,18 +224,28 @@ checkPlugins()
pluginFolder=/resources/addons/plugins
if [ -d ${pluginFolder} ] && [ "$(ls $pluginFolder)" ]; then
print_Debug "Adding Plug-in Jars"
echo -e "name=Addons Factory\ntype=bw6\nlayout=bw6ext\nlocation=$BWCE_HOME/tibco.home/addons" > `echo $BWCE_HOME/tibco.home/bw*/*/ext/shared`/addons.link


if [ $TCI_BW_EDITION != "ipaas" ]; then
HOME=$BWCE_HOME/tibco.home
else
HOME=$TCI_HOME/ext/shared
fi

echo -e "name=Addons Factory\ntype=bw6\nlayout=bw6ext\nlocation=$HOME/addons" > `echo $BWCE_HOME/tibco.home/bw*/*/ext/shared`/addons.link
for name in $(find $pluginFolder -type f);
do
# filter out hidden files
if [[ "$(basename $name )" != .* ]]; then
unzip -q -o $name -d $BWCE_HOME/plugintmp/
mkdir -p $BWCE_HOME/tibco.home/addons/runtime/plugins/ && mv $BWCE_HOME/plugintmp/runtime/plugins/* "$_"
mkdir -p $BWCE_HOME/tibco.home/addons/lib/ && mv $BWCE_HOME/plugintmp/lib/*.ini "$_"${name##*/}.ini
mkdir -p $BWCE_HOME/tibco.home/addons/lib/ && mv $BWCE_HOME/plugintmp/lib/*.jar "$_" 2> /dev/null || true
mkdir -p $BWCE_HOME/tibco.home/addons/bin/ && mv $BWCE_HOME/plugintmp/bin/* "$_" 2> /dev/null || true
find $BWCE_HOME/plugintmp/* -type d ! \( -name "runtime" -o -name "bin" -o -name "lib" \) -exec mv {} / \; 2> /dev/null
if [[ "$(basename $name )" != .* ]];then
unzip -q -o $name -d $BWCE_HOME/plugintmp/
mkdir -p $HOME/addons/runtime/plugins/ && mv $BWCE_HOME/plugintmp/runtime/plugins/* "$_"
mkdir -p $HOME/addons/lib/ && mv $BWCE_HOME/plugintmp/lib/*.ini "$_"${name##*/}.ini
mkdir -p $HOME/addons/lib/ && mv $BWCE_HOME/plugintmp/lib/*.jar "$_" 2> /dev/null || true
mkdir -p $HOME/addons/bin/ && mv $BWCE_HOME/plugintmp/bin/* "$_" 2> /dev/null || true
if [ $TCI_BW_EDITION != "ipaas" ]; then
find $BWCE_HOME/plugintmp/* -type d ! \( -name "runtime" -o -name "bin" -o -name "lib" \) -exec mv {} /tmp \; 2> /dev/null
else
find $BWCE_HOME/plugintmp/* -type d ! \( -name "runtime" -o -name "bin" -o -name "lib" \) -exec mv {} /opt/tibco \; 2> /dev/null
fi
rm -rf $BWCE_HOME/plugintmp/
fi
done
Expand Down Expand Up @@ -283,21 +301,17 @@ checkCerts()
checkAgents()
{
agentFolder=/resources/addons/monitor-agents

if [ -d ${agentFolder} ] && [ "$(ls $agentFolder)" ]; then
print_Debug "Adding monitoring jars"

for name in $(find $agentFolder -type f);
do
# filter out hidden files
if [[ "$(basename $name )" != .* ]];then
mkdir -p $BWCE_HOME/agent/
unzip -q $name -d $BWCE_HOME/agent/
fi
done

do
# filter out hidden files
if [[ "$(basename $name )" != .* ]];then
mkdir -p $BWCE_HOME/agent/
unzip -q $name -d $BWCE_HOME/agent/
fi
done
fi

}

memoryCalculator()
Expand Down Expand Up @@ -337,11 +351,11 @@ checkJavaGCConfig()

checkJAVAHOME()
{
if [[ ${JAVA_HOME} ]]; then
print_Debug $JAVA_HOME
else
export JAVA_HOME=$BWCE_HOME/tibco.home/tibcojre64/1.8.0
fi
if [[ ${JAVA_HOME} ]]; then
print_Debug $JAVA_HOME
else
export JAVA_HOME=$BWCE_HOME/tibco.home/tibcojre64/1.8.0
fi
}

checkThirdPartyInstallations()
Expand Down Expand Up @@ -415,27 +429,78 @@ then
cp -r /resources/addons/jars/* `echo $BWCE_HOME/tibco.home/bw*/*`/system/hotfix/shared
fi
fi
ln -s /*.ear `echo $BWCE_HOME/tibco.home/bw*/*/bin`/bwapp.ear
sed -i.bak "s#_APPDIR_#$BWCE_HOME#g" $BWCE_HOME/tibco.home/bw*/*/config/appnode_config.ini
unzip -qq `echo $BWCE_HOME/tibco.home/bw*/*/bin/bwapp.ear` -d /tmp
setLogLevel
memoryCalculator
checkEnvSubstituteConfig
if [ $TCI_BW_EDITION != "ipaas" ]; then
ln -s /*.ear `echo $BWCE_HOME/tibco.home/bw*/*/bin`/bwapp.ear
sed -i.bak "s#_APPDIR_#$BWCE_HOME#g" $BWCE_HOME/tibco.home/bw*/*/config/appnode_config.ini
unzip -qq `echo $BWCE_HOME/tibco.home/bw*/*/bin/bwapp.ear` -d /tmp
setLogLevel
memoryCalculator
checkEnvSubstituteConfig
fi
fi

checkProfile
checkPolicy
setupThirdPartyInstallationEnvironment

if [ -f /*.substvar ]; then
cp -f /*.substvar $BWCE_HOME/tmp/pcf.substvar # User provided profile
else
cp -f /tmp/META-INF/$BW_PROFILE $BWCE_HOME/tmp/pcf.substvar
if [ $TCI_BW_EDITION != "ipaas" ]; then
checkProfile
checkPolicy
setupThirdPartyInstallationEnvironment
if [ -f /*.substvar ]; then
cp -f /*.substvar $BWCE_HOME/tmp/pcf.substvar # User provided profile
else
cp -f /tmp/META-INF/$BW_PROFILE $BWCE_HOME/tmp/pcf.substvar
fi
$JAVA_HOME/bin/java -cp `echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.bwce.profile.resolver_*.jar`:`echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.tpcl.com.fasterxml.jackson_*`/*:`echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.bw.tpcl.org.codehaus.jettison_*`/*:$BWCE_HOME:$JAVA_HOME/lib -DBWCE_APP_NAME=$bwBundleAppName com.tibco.bwce.profile.resolver.Resolver
STATUS=$?
if [ $STATUS == "1" ]; then
exit 1 # terminate and indicate error
fi
fi

$JAVA_HOME/bin/java -cp `echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.bwce.profile.resolver_*.jar`:`echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.tpcl.com.fasterxml.jackson_*`/*:`echo $BWCE_HOME/tibco.home/bw*/*/system/shared/com.tibco.bw.tpcl.org.codehaus.jettison_*`/*:$BWCE_HOME:$JAVA_HOME/lib -DBWCE_APP_NAME=$bwBundleAppName com.tibco.bwce.profile.resolver.Resolver
if [ $TCI_BW_EDITION == "ipaas" ];
then
echo "$(date "+%H:%M:%S.000") INFO ######################## Setting up TCI environment start #######################"
tci_java_home="/usr/lib/jvm/java"
BW_VERSION=`ls $BWCE_HOME/tibco.home/bw*/`

#copy runtime zip in TCI_HOME
if [ -d $BWCE_HOME/tibco.home/bwce/${BW_VERSION} ]; then
yes | cp -r $BWCE_HOME/tibco.home/bwce/${BW_VERSION}/* $TCI_HOME
fi
if [ -d $BWCE_HOME/tibco.home/addons/lib ]; then
yes | cp -r $BWCE_HOME/tibco.home/addons/lib $TCI_HOME/ext/shared
fi

STATUS=$?
if [ $STATUS == "1" ]; then
exit 1 # terminate and indicate error
echo "$(date "+%H:%M:%S.000") INFO Copied runtime zip in TCI home: " $TCI_HOME

#Modify TRA files to use new TCI home = /opt/tibco/bwcloud/<cloudversion>
cd $TCI_HOME/bin

#TODO: check without tra modification
#Modify bwappnode & bwappnode.tra file in runtime zip
echo -e "\nexport TIBCO_JAVA_HOME=${tci_java_home} \ntibco.include.tra=${TCI_HOME}/bin/bwcommon.tra" >> bwappnode
sed -i "s+$APPDIR/tibco.home+/opt/tibco+g" bwappnode
sed -i "s+bwce/${BW_VERSION}+bwcloud/${CLOUD_VERSION}+g" bwappnode

#Change paths in bwcommon.tra file. check if FTL home need to be added in the path
sed -i "s+%APPDIR%/tibco.home+/opt/tibco+g" bwcommon.tra
sed -i "s+tibco.product.folder=bwce/${BW_VERSION}+tibco.product.folder=bwcloud/${CLOUD_VERSION}+g" bwcommon.tra
sed -i 's+tibco.env.product.type=bwce+tibco.env.product.type=bwcloud+g' bwcommon.tra

#Modify appnode_config.ini
sed -i 's+osgi.console.ssh=1122+osgi.console=1122+g' $TCI_HOME/config/appnode_config.ini
sed -i 's+osgi.console.enable.builtin=false+# osgi.console.enable.builtin=false+g' $TCI_HOME/config/appnode_config.ini
sed -i 's+osgi.console.ssh.useDefaultSecureStorage=true+# osgi.console.ssh.useDefaultSecureStorage=true+g' $TCI_HOME/config/appnode_config.ini
sed -i "s+java.security.auth.login.config=_APPDIR_/tibco.home/bwce/${BW_VERSION}/config/equinox.console.jass.login.conf+# java.security.auth.login.config=_APPDIR_/tibco.home/bwce/${BW_VERSION}/config/equinox.console.jass.login.conf+g" $TCI_HOME/config/appnode_config.ini
sed -i "s+ssh.server.keystore=_APPDIR_/tibco.home/bwce/${BW_VERSION}/repo/hostkey.ser+# ssh.server.keystore=_APPDIR_/tibco.home/bwce/${BW_VERSION}/repo/hostkey.ser+g" $TCI_HOME/config/appnode_config.ini
sed -i "s+org.eclipse.equinox.console.jaas.file=_APPDIR_/tibco.home/bwce/${BW_VERSION}/repo/store+# org.eclipse.equinox.console.jaas.file=_APPDIR_/tibco.home/bwce/${BW_VERSION}/repo/store+g" $TCI_HOME/config/appnode_config.ini
sed -i 's+org.eclipse.equinox.http.jetty.autostart=true+# org.eclipse.equinox.http.jetty.autostart=true+g' $TCI_HOME/config/appnode_config.ini
sed -i 's+bw.frwk.event.subscriber.metrics.enabled=false+# bw.frwk.event.subscriber.metrics.enabled=false+g' $TCI_HOME/config/appnode_config.ini
sed -i 's+_APPDIR_/tibco.home+/opt/tibco+g' $TCI_HOME/config/appnode_config.ini

#Clean up
rm -rf $TCI_HOME/bin/startBWAppNode.sh
rm -rf $TCI_HOME/bin/bwappnode.script.sh
rm -rf $TCI_HOME/bin/bwappnode.tra
echo "$(date "+%H:%M:%S.000") INFO ######################## Setting up TCI environment end #######################"

fi

16 changes: 16 additions & 0 deletions reducedStartupTime/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#Set ENV Variables
export BWCE_HOME=/tmp
export APPDIR=${BWCE_HOME}
export MALLOC_ARENA_MAX=2
export MALLOC_MMAP_THRESHOLD_=1024
export MALLOC_TRIM_THRESHOLD_=1024
export MALLOC_MMAP_MAX_=65536
export BW_KEYSTORE_PATH=/resources/addons/certs
. ./scripts/setup.sh null null null $BWCE_HOME
STATUS=$?
if [ $STATUS == "1" ]; then
echo "ERROR: Failed to setup BWCE runtime. See logs for more details."
exit 1
fi
exec bash $BWCE_HOME/tibco.home/bw*/*/bin/startBWAppNode.sh

0 comments on commit 8387170

Please sign in to comment.