• Tomcat 自动化部署


    Tomcat 自动化部署脚本

    使用方法: ./autodeploy.sh test

    其中autodeploy.sh 为脚本的文件名, test为war的文件名。

    #!/bin/sh
    now=`date +%Y%m%d%H%M%S`
    echo $now
    tomcat_path="/home/larry/tomcat8.0.45"
    backup_path="/home/larry/tomcat8.0.45/backup"
    
    war=$1
    if [ -e $1.war ]; then
      echo -e "33[34m war achive : '$1.war' exists 33[0m"
    else
      echo -e "33[31m war achive : $1.war not exists 33[0m"
      exit 
    fi
    
    #change color
    echo -e "33[34m"
    
    #create backup dir
    if [ ! -d "$backup_path" ]; then
      mkdir "$backup_path"
    fi
    
    echo "tomcat home: $tomcat_path"
    echo "backup path: $backup_path"
    echo 'try to stop tomcat...'
    pid=`ps aux|grep "java" | grep "$tomcat_path" | awk '{printf $2}'`
    if [ -n $pid ]; then
    echo "tomcat pid: $pid";
    kill -9 $pid;
    fi
    
    echo 'stop tomcat finished...'
    echo 'back old archive...'
    
    echo $tomcat_path/webapps/$war.war
    
    if [ -f "$tomcat_path/webapps/$war.war" ]; then
    mv -v "$tomcat_path/webapps/$war.war" "$backup_path/$1_$now.war";
    fi
    
    rm -rf $tomcat_path/webapps/$war*
    
    echo "copy $war.war archive to webapps.."
    cp -v "$war.war" "$tomcat_path/webapps/"
    
    
    
    echo -e "33[32m"
    
    echo 'startup tomcat...'
    
    sh $tomcat_path/bin/startup.sh
    
    tail -10f $tomcat_path/logs/catalina.out
    

      

  • 相关阅读:
    Java作业5.17
    上机作业5.14
    android 计算器
    安卓第四周作业
    课后作业
    5.28上机作业
    5.22作业
    5.21 作业
    5.20作业
    上机作业5.14
  • 原文地址:https://www.cnblogs.com/linlf03/p/7677135.html
Copyright © 2020-2023  润新知