centos自动打包并布署项目

  1. 网上下载ftp工具类PLINK.EXE和PSFTP.EXE

  2. 编写bat脚本如下

  3. set taget=192.168.1.11
    cd ../..
    call mvn package
    echo pack over ftp to 192.168.1.11
    call F:\leech\tools\ftp\psftp -l appuser -pw appuser -b src\autoinstall\ftp.txt %taget%
    echo down ftp install in 192.168.1.11
    call F:\leech\tools\ftp\plink -v -pw appuser -m src\autoinstall\install.txt appuser@%taget%
    cd src/autoinstall
  4. 编写ftp.txt如下

  5. put target\test.war
    bye
  6. 编写install.txt如下

  7. javapid=$(ps -ef | grep tomcat | grep -v grep | awk '{print $2}')
    if [ ! -n "$javapid" ]; then 
      echo "progress not up" 
    else 
      kill -15 $javapid
    fi  
    
    
    current=$(date +%Y%m%d)
    
    mv /home/appuser/test.war /opt/hsserv/
    cd /opt/hsserv/
    mv test-web "test-web-${current}"
    mkdir test-web
    unzip test.war -d test-web
    
    rm -rf /opt/hsserv/test-web/WEB-INF/classes/hazelcast-client.xml
    
    cp "/opt/hsserv/test-web-${current}/WEB-INF/classes/dubbo.properties" /opt/hsserv/test-web/WEB-INF/classes/
    cp "/opt/hsserv/test-web-${current}/WEB-INF/classes/ecms_config.xml" /opt/hsserv/test-web/WEB-INF/classes/
    cp "/opt/hsserv/test-web-${current}/WEB-INF/classes/gateway.properties" /opt/hsserv/test-web/WEB-INF/classes/
    cp "/opt/hsserv/test-web-${current}/WEB-INF/classes/jdbc.properties" /opt/hsserv/test-web/WEB-INF/classes/
    
    rm -rf /opt/hsserv/test.war
    rm -rf /opt/apache-tomcat-7.0.56/work/
    rm -rf /opt/apache-tomcat-7.0.56/logs/*
    rm -rf /var/hslog/test/*
    
    
    
    echo $javapid
    echo $current
    
    cd  /opt/apache-tomcat-7.0.56/bin
    ./startup.sh
    
    echo "result:$?"
    
    exit



你可能感兴趣的:(centos自动打包并布署项目)