Showing posts with label Deployment. Show all posts
Showing posts with label Deployment. Show all posts

Thursday, 28 August 2014

A sample ant build script and its explaination

A sample build script is given below . Please refer comments for explaination

<?xml version="1.0" ?>
<!-- Default compilation action for ant build -->
<project name="<Your application>" default="compile">
<path id="compile.classpath">
<fileset dir="WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- init target for ant build -->
<!-- creates classes , conf , dist folders. -->
<target name="init">
<delete dir="WEB-INF/classes"/>
<mkdir dir="WEB-INF/classes/conf"/>
<mkdir dir="dist" />
</target>
<!-- As specified in project tag default action in build will be called -->
<target name="compile" depends="init" >
<!-- Compile all classes and copy them to WEB-INF/classes -->
<javac destdir="WEB-INF/classes" debug="true" srcdir="src">
<classpath refid="compile.classpath"/>
</javac>

<copy todir="WEB-INF/classes">
<fileset dir="conf"/>
</copy>
</target>
<!-- Compile and package the classes to a war -->
<target name="war">
<war destfile="dist/s31.war" webxml="WEB-INF/web.xml">
<fileset dir="../dist"/>
<lib dir="WEB-INF/lib"/>
<classes dir="WEB-INF/classes"/>
</war>
</target>
</project>

Monday, 18 August 2014

A sample shell script to deploy your application in tomcat7 ubuntu.

A sample shell script to deploy your application in tomcat7 ubuntu.

#/bin/sh
echo -e  "Enter your name - \c "
read name
echo -e  "Enter your password - \c "
read password

################ Used to stop the tomcat #################################
function stop_tomcat(){
      sudo service tomcat7 stop
       return ;
}

################ Used to start the tomcat #################################
function start_tomcat(){
      sudo service tomcat7 start
      status = `echo $?`
      if [ $status -ge 0 ]
      then
    echo "Error starting tomcat "
    exit
       fi


      return ;
}
######################end ################################################


######################### copy the war to webapps ########################
function copy_war(){
       echo "Copying war ------------------"
       sudo cp ~/patch/.war /var/lib/tomcat7/webapps
       ls -ltr /var/lib/tomcat7/webapps/
       start_tomcat
       echo " ---------------- patch complete --------------------"
}

############################end###########################################


######################### copy the war to webapps ########################
function code_base_patch(){
       echo "Code base patching"
       unrar  x ~/patch/.rar /var/lib/tomcat7/webapps//
       cd /var/lib/tomcat7/webapps//
       ant
       start_tomcat
       echo " ---------------- patch complete --------------------"
}

############################end###########################################




if  [ $name = "dev" ]
then
     if [ $password = "dev" ]
     then
if [ -f "patch_log.log" ]
then
    echo "Patch started on `date` by - " $name >> patch_log.log
else
    touch patch_log.log
fi
stop_tomcat
echo -e "Enter mode of deployment - \c"
         read mode
if [ $mode = "war" ]
           then
              copy_war
  else
     code_base_patch
             
         fi
      fi
else
     echo "Invalid username/password please try again "
fi