新版发布程序

<pre name="code" class="sql"><pre name="code" class="sql"><pre name="code" class="sql">#!/bin/sh
#
#    程序名称         : tb.sh
#    程序功能         : 同步前置机参数文件
#    系统名称         : 浙江稠州商业银行综合业务系统
#    版    本         : 1.00
#
#    OS & Environment : Sco Unix 5.0.X
#
#
#    History          :
#
#      Date         Position   Author        Description
# --------------------------------------------------------------
#     2015-05-13               Scan
#     2015-05-30               Scan
#

trap "" 2 3 15
echo
curdate=`date  '+%Y%m%d'`
#curdate=`date  '+%Y%m%d'`
dis_mainpublish="ZJZC-应用发布程序"
cat <<mayday
                	DATE:$curdate
	--------------------------------------------------
	             $dis_mainpublish
	--------------------------------------------------
	****** 1) "备份应用" *******
	****** 2) "FTP取发布包" *******
	****** 3) "更新应用" *******
	****** 4) "退出系统"   *******
mayday
	echo -n "please choose [1-2-3-4]:"
	read ANS
	case $ANS in
        1)
               cd /usr/local/apache-tomcat-7.0.55_8081/webapps
               tar -czvf zjzc-web-flow.$curdate.tar.gz zjzc-web-flow
               ls -ltr *.tar.gz
        ;;
        2)
         cd /usr/local/apache-tomcat-7.0.55_8081/webapps/zjzc-web-flow
         if [ -f zjzc-web-flow-*.war ]
            then
                   echo zjzc-web-flow-*.war 
                   File=`echo  zjzc-web-flow-*.war`
                   echo "是否删除$File(y|Y)"
                   read ANS
                   if [ "$ANS" = 'Y' ] || [ "$ANS" = 'y' ]
                      then
                      rm -f $File
                      else
                      exit
                   fi
ftp -n<<!
             open 15.26.10.2
             user publish xxxxx
             pass
             bin
             prompt
             mget zjzc-web-flow-*.war
             mdelete  zjzc-web-flow-*.war
             exit
!
                 if [ -f zjzc-web-flow-*.war ]
                    then
                    echo "取的文件为`ls -lr zjzc-web-flow-*.war`"
                    else
                    echo "请确认文件是否上传"
                    exit
                fi

         else
 ftp -n<<!
             open 1.36.60.2
             user publish xxxxxx
             pass
             bin
             prompt
             mget zjzc-web-flow-*.war
             mdelete  zjzc-web-flow-*.war
             exit
!
                 if [ -f zjzc-web-flow-*.war ]
                     then
                     echo "取的文件为`ls -lr zjzc-web-flow-*.war`"
                     else
                     echo "请确认文件是否上传"
                     exit
                fi
          fi
         ;;
        3)
          echo "请确认是否已上传最新的war包,否则禁止发布(y|Y)"
             read ANS
          if [ "$ANS" = 'Y' ] || [ "$ANS" = 'y' ]
             then 
                    echo "停止tomcat应用"
                    cd /usr/local/apache-tomcat-7.0.55_8081/bin
                    sh ./shutdown.sh 
	            sleep 5 
                     if  [ $(ps -ef | grep java | grep -v grep | wc -l ) -ne 0 ]
                        then
                                echo "java进程为"
                                ps -ef | grep java | grep -v grep
                                echo "Tomcat 无法停止是否继续(y|Y|N|n)"
                                read ANS
                                if [ "$ANS" = 'Y' ] || [ "$ANS" = 'y' ]
                                    then
                                         kill -9 `ps -ef | grep java | grep -v grep | awk '{print $2}'`
                                         echo "Tomcat 无法正常停止 强制killed"
				         cd /usr/local/apache-tomcat-7.0.55_8081/webapps/zjzc-web-flow
                                         FILE=`echo zjzc-web-flow-*.war`
                                         echo -e "请确认是否包发布$red$FILE$white(y|Y)"
                                         read ANS
                                         if [ "$ANS" = 'Y' ] || [ "$ANS" = 'y' ]
                                            then
                                            unzip -o $FILE
                                            else
                                            exit
                                         fi
                                        cd /etc/scripts/change
                                        sh ./a.sh
                                        cd  /usr/local/apache-tomcat-7.0.55_8081/bin
		                        echo "开始启动tomcat"
                                        sh ./startup.sh
		                   else
	                           exit 2
		                fi	  
                      else
                      cd /usr/local/apache-tomcat-7.0.55_8081/webapps/zjzc-web-flow
                      FILE=`echo zjzc-web-flow-*.war`
                      echo -e "请确认是否包发布$red$FILE$white(y|Y)"
                      read ANS
                            if [ "$ANS" = 'Y' ] || [ "$ANS" = 'y' ]
                               then
                               unzip -o $FILE
                               else
                               exit
                             fi
                             cd /etc/scripts/change
                             sh ./a.sh
                             cd  /usr/local/apache-tomcat-7.0.55_8081/bin
                             echo "开始启动tomcat"
                             sh ./startup.sh
                     fi
          else
          exit 1
          fi
        ;;
	4)
	     echo "退出菜单"
	     exit 0
		;;
	esac


 
 
 
 
 
 
 
 
 

你可能感兴趣的:(新版发布程序)