weblogic auto deployment script
Purpose : This script will copy the ear file from specific location and uninstall and install same ear file on the weblogic cluster . After the script will bounce the server .
## General Srcipt for Preprod App server , which have two Maneged servers
## Config Variables
ADMINSERVERIP=10.192.168.1
ADMINSERVERPORT=7050
APPSERVER1IP=10.192.168.1
APPSERVER2IP=10.192.168.2
APPSERVER1PORT=8004
APPSERVER2PORT=9004
APPSERVER1NAME=appserver1
APPSERVER2NAME=appserver2
TARGET=mycluster
USERNAME=weblogic
PASSWORD=welcome1
APPLIB=/opt/app/bea/wls81sp6/user_projects/WLS1/applications
WLSDIR=/opt/app/bea/wls81sp6/user_projects/WLS1
SOURCE=/tmp
APPFILE=app.ear
APPILICATION=application
MAILLIST="yoyo.prod.support@company.com"
MAILSENDER="machineIP.host@@company.com"
MAILSUB="Deployment Status application PREPROD "
#### script starts from here
if ! id | grep oracle
then
echo " please run as oracle "
exit 90
fi
## /tmp/tt is the message file for the email content
mv /tmp/tt /tmp/tt.last
touch /tmp/tt
## sourcing evn file for jars required to run deployer utility
. $WLSDIR/bin/setDomainEnv.sh
if java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD GETSTATE | grep RUNNING
then
echo " Server is Running , Going for Deployment "
else
echo " Server is Not Running, Please Start Manually "
exit 97
fi
cd $APPLIB
mv $APPFILE $APPFILE`date +%m%d%Y_%H%M `
cp $SOURCE/$APPFILE .
chmod 755 $APPFILE
ls -ltr >> /tmp/tt
cksum $APPFILE >> /tmp/tt
if [ -f $APPFILE ]
then
echo " file copied successfully "
else
echo " error in copying " >>/tmp/tt
echo " error in copying "
exit 96
fi
echo >> /tmp/tt
echo " ^^^^^^^^^^^^^ Undeployment For $APPFILE ^^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
if java weblogic.Deployer -url t3://$ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD -targets $TARGET -name $APPILICATION -undeploy >> /tmp/tt
then
echo "File Undeployed Going for Deployment "
else
echo "Error in UnDeployment Exiting .... "
echo "Error in UnDeployment Exiting .... " >> /tmp/tt
mailx -s $MAILSUB $MAILLIST < /tmp/tt
exit 99
fi
echo >> /tmp/tt
echo "^^^^^^^^^^^^^ Deployment For $APPFILE ^^^^^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
if java weblogic.Deployer -url t3://$IP:$PORT -username $USERNAME -password $PASSWORD -targets EBPPCluster -name $TARGET -deploy $APPLIB/$APPFILE1 >> /tmp/tt
then
echo "File deployed Going for Bouncing The Server "
echo "File deployed Going for Bouncing The Server ">> /tmp/tt
else
echo "Error in Deployment Exiting .... "
echo "Error in Deployment Exiting .... " >> /tmp/tt
mailx -s $MAILSUB $MAILLIST < /tmp/tt
exit 98
fi
echo >> /tmp/tt
echo " ^^^^^^^^^^^^ Killing the server ^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
java weblogic.Admin -url $APPSERVER1IP:$APPSERVER1PORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
java weblogic.Admin -url $APPSERVER2IP:$APPSERVER2PORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
echo >> /tmp/tt
sleep 5
# this is custom made script
cd $WLSDIR
./startAdmin1.sh
#./startWeblogic.sh &
count=0
while [ $count -le 120 ]
do
if netstat -an | grep $PORT | grep LISTEN
then
echo " Server is UP "
break
else
sleep 10
count=`expr $count + 10`
fi
done
if netstat -an | grep $PORT | grep LISTEN >> /tmp/tt
then
echo " Server is UP after $count sec " >> /tmp/tt
else
echo " Server is not UP after $count sec Please check Manually " >> /tmp/tt
fi
## starting managed servers ,Node manager should be configured if not, start manually
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPOR -username $USERNAME -password $PASSWORD START APPSERVER1NAME
sleep 60
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPOR -username $USERNAME -password $PASSWORD START APPSERVER2NAME
mailx -r $MAILSENDER -s $MAILSUB $MAILLIST < /tmp/tt
Purpose : This script will copy the ear file from specific location and uninstall and install same ear file on the weblogic cluster . After the script will bounce the server .
## General Srcipt for Preprod App server , which have two Maneged servers
## Config Variables
ADMINSERVERIP=10.192.168.1
ADMINSERVERPORT=7050
APPSERVER1IP=10.192.168.1
APPSERVER2IP=10.192.168.2
APPSERVER1PORT=8004
APPSERVER2PORT=9004
APPSERVER1NAME=appserver1
APPSERVER2NAME=appserver2
TARGET=mycluster
USERNAME=weblogic
PASSWORD=welcome1
APPLIB=/opt/app/bea/wls81sp6/user_projects/WLS1/applications
WLSDIR=/opt/app/bea/wls81sp6/user_projects/WLS1
SOURCE=/tmp
APPFILE=app.ear
APPILICATION=application
MAILLIST="yoyo.prod.support@company.com"
MAILSENDER="machineIP.host@@company.com"
MAILSUB="Deployment Status application PREPROD "
#### script starts from here
if ! id | grep oracle
then
echo " please run as oracle "
exit 90
fi
## /tmp/tt is the message file for the email content
mv /tmp/tt /tmp/tt.last
touch /tmp/tt
## sourcing evn file for jars required to run deployer utility
. $WLSDIR/bin/setDomainEnv.sh
if java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD GETSTATE | grep RUNNING
then
echo " Server is Running , Going for Deployment "
else
echo " Server is Not Running, Please Start Manually "
exit 97
fi
cd $APPLIB
mv $APPFILE $APPFILE`date +%m%d%Y_%H%M `
cp $SOURCE/$APPFILE .
chmod 755 $APPFILE
ls -ltr >> /tmp/tt
cksum $APPFILE >> /tmp/tt
if [ -f $APPFILE ]
then
echo " file copied successfully "
else
echo " error in copying " >>/tmp/tt
echo " error in copying "
exit 96
fi
echo >> /tmp/tt
echo " ^^^^^^^^^^^^^ Undeployment For $APPFILE ^^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
if java weblogic.Deployer -url t3://$ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD -targets $TARGET -name $APPILICATION -undeploy >> /tmp/tt
then
echo "File Undeployed Going for Deployment "
else
echo "Error in UnDeployment Exiting .... "
echo "Error in UnDeployment Exiting .... " >> /tmp/tt
mailx -s $MAILSUB $MAILLIST < /tmp/tt
exit 99
fi
echo >> /tmp/tt
echo "^^^^^^^^^^^^^ Deployment For $APPFILE ^^^^^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
if java weblogic.Deployer -url t3://$IP:$PORT -username $USERNAME -password $PASSWORD -targets EBPPCluster -name $TARGET -deploy $APPLIB/$APPFILE1 >> /tmp/tt
then
echo "File deployed Going for Bouncing The Server "
echo "File deployed Going for Bouncing The Server ">> /tmp/tt
else
echo "Error in Deployment Exiting .... "
echo "Error in Deployment Exiting .... " >> /tmp/tt
mailx -s $MAILSUB $MAILLIST < /tmp/tt
exit 98
fi
echo >> /tmp/tt
echo " ^^^^^^^^^^^^ Killing the server ^^^^^^^^^ at "` date +%H:%M:%S ` >> /tmp/tt
echo >> /tmp/tt
java weblogic.Admin -url $APPSERVER1IP:$APPSERVER1PORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
java weblogic.Admin -url $APPSERVER2IP:$APPSERVER2PORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPORT -username $USERNAME -password $PASSWORD FORCESHUTDOWN >> /tmp/tt
echo >> /tmp/tt
sleep 5
# this is custom made script
cd $WLSDIR
./startAdmin1.sh
#./startWeblogic.sh &
count=0
while [ $count -le 120 ]
do
if netstat -an | grep $PORT | grep LISTEN
then
echo " Server is UP "
break
else
sleep 10
count=`expr $count + 10`
fi
done
if netstat -an | grep $PORT | grep LISTEN >> /tmp/tt
then
echo " Server is UP after $count sec " >> /tmp/tt
else
echo " Server is not UP after $count sec Please check Manually " >> /tmp/tt
fi
## starting managed servers ,Node manager should be configured if not, start manually
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPOR -username $USERNAME -password $PASSWORD START APPSERVER1NAME
sleep 60
java weblogic.Admin -url $ADMINSERVERIP:$ADMINSERVERPOR -username $USERNAME -password $PASSWORD START APPSERVER2NAME
mailx -r $MAILSENDER -s $MAILSUB $MAILLIST < /tmp/tt