Hi there,
I am very new on shell scripting. can anyone please help me to start the process on foreground instead of background
#!/bin/bash
JAVA_HOME=/U01/Nova/installed/jdk1.8.0_101
SCRIPT_PATH=/U01/MAS/bin
MAS_LOGS_DIR=/U01/Logs/MAS/mas
MAS_CONF_DIR=/U01/MAS/conf
function create_property_file()
{
IP="127.0.0.1"
PORT="8500"
ENV="QCVMWARE"
PRO_NAME="MAS"
DATA=`curl "http://$IP:$PORT/v1/kv/$ENV/$PRO_NAME/$1/?recurse"|python -c '
import json,sys
obj=json.load(sys.stdin)
for cvbd in obj:
wery = cvbd["Key"].split("/")
if not (cvbd["Value"] is None) : print wery[len(wery)-1]+","+cvbd["Value"]
else : print wery[len(wery)-1]+","+" " '`
mkdir -p /U01/MAS/conf/
while IFS="," read f1 f2
do
KEY="$f1"
if [ "$f2" != "null" ]
then
VALUE=`echo "$f2"| base64 --decode`
echo "$KEY=$VALUE" >> /U01/MAS/conf/$1.properties
else
echo "$KEY=" >> /U01/MAS/conf/$1.properties
fi
done <<< "$DATA"
}
function process_pid(){
PID=`ps -ef | grep '/U01/MAS/apps/mas/MAS.jar' | grep -v grep | awk '{ print $2 }'`
}
function create_bootstrap_file()
{
echo "spring.cloud.consul.config.failFast=false" >> /U01/MAS/conf/bootstrap.properties
echo "spring.cloud.consul.config.prefix=QCVMWARE" >> /U01/MAS/conf/bootstrap.properties
echo "spring.cloud.consul.host=127.0.0.1" >> /U01/MAS/conf/bootstrap.properties
echo "spring.cloud.consul.port=8500" >> /U01/MAS/conf/bootstrap.properties
echo "spring.cloud.consul.config.watch.enabled=false" >> /U01/MAS/conf/bootstrap.properties
}
export MAS_LOGS_DIR="/U01/Logs/MAS/mas"
export MAS_CONF_DIR="/U01/MAS/conf"
rm -rf /U01/MAS/conf/*
create_bootstrap_file
create_property_file "application"
create_property_file "mongo"
create_property_file "swagger"
create_property_file "tenant-settings"
create_property_file "tms"
create_property_file "iRequest_messages_en"
create_property_file "iAnalyze_messages_en"
create_property_file "iAnalyze_messages_hi"
create_property_file "messages_hi"
create_property_file "messages_en"
# Kill existing process if exists
process_pid
kill -9 $PID
#Start Server
$JAVA_HOME/bin/java -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark -Dfile.encoding=UTF-8-Xms2g -Xmx2g -Duser.timezone=IST -jar /U01/MAS/apps/mas/MAS.jar --spring.config.location=/U01/MAS/conf/application.properties,/U01/MAS/conf/mongo.properties,/U01/MAS/conf/swagger.properties,/U01/MAS/conf/tenant-settings.properties,/U01/MAS/conf/tms.properties,/U01/MAS/conf/bootstrap.properties &
echo 'process started'
echo 'Sleeping for 10s'
sleep 10s
#echo `ps -ef | grep mas | grep -v grep | awk '{print $2}'` > $SCRIPT_PATH/MAS.pid
#ps -ef | grep '/U01/MAS/apps/mas/MAS.jar' | grep -v grep | awk '{ print $2 }' > /U01/MAS/bin/test/MAS.pid
process_pid
echo $PID > $SCRIPT_PATH/MAS.pid
#echo $PID > /U01/MAS/data/mas/pid
processCount=`ps -ef | grep /U01/MAS/apps/mas/MAS.jar | grep -v grep | wc -l`
if [[ $processCount == '1' ]]; then
echo "MAS Started Successfully" > $SCRIPT_PATH/MAS.log
echo "MAS Started Successfully"
fi