zoukankan      html  css  js  c++  java
  • tomcat快速部署脚本

    #!/bin/bash
    #-*- coding: utf-8 -*-
    #Date:   2018/12/28
    #Author:  Mr.yang
    #脚本可根据需求修改
    
    
    tomcat6="tomcat6版本"
    tomcat7="tomcat7版本"
    tomcat8="tomcat8版本"
    i="0"
    
    read -p "请输入项目名不含任何符号(例:aaa):" pjname && read -p "请输入安装目录绝对路径(例/test/test):" installation
        mkdir -p ${installation}
    read -p "请输入tomcat版本(tomcat+6/7/8):" tomcat
        cd $installation
        if [ $tomcat == tomcat6 ];then
            wget $tomcat6
        elif [ $tomcat == tomcat7 ];then
            wget $tomcat7
        elif [ $tomcat == tomcat8 ];then
            wget $tomcat8
        fi
    read -p "请输入日志目录(例/logs/backup):" logs && mkdir -p $logs
    read -p "请输入平台名称:" platform && read -p "请输入用户密码:" passwd
        useradd ${platform}${pjname}
        echo "$passwd" | passwd --stdin ${platform}${pjname}
    read -p "请输入端口号:(关闭端口号自动+1000)" prot
        while [ $i -le 3 ]
        do
            fin=`find /web/ -depth -name "*$prot"| awk -F"[/_]+" '{print $5}' | wc -l`
            find /web/ -depth -name "*$prot"| awk -F"[/_]+" '{print $5}' | wc -l
            if [ $fin != 0 ];then
                echo "端口目录存在……" && read -p "请重新输入端口号:" prot
                i=$((i+1))
                if [ $i -lt 3 ];then
                    continue
                elif [ $i -eq 3 ];then
                    echo "请仔细核对端口后,再次执行……"
                    exit
                fi
                ps -ef |grep $prot | grep -v grep
                if [ $? -eq 0 ];then
                    echo "启用端口重复……" && read -p "请重新输入:" prot
                elif [ $? -ne 0 ];then
                    echo "无端口重复,继续进行……"
                fi
            elif [ $fin == 0 ];then
                echo "无端口重复……"
                break
            fi
        done
        echo "创建中……请稍后……"
        tar=`ls | awk '/jdk/{print}'`
        tar xf ${installation}${tar} && rm -rf ${installation}${tar}
        gz=`ls | awk 'NR==1{print $1}'`
        mv $gz tomcat_${prot}
        sed -i "s/8080/${prot}/g" ${installation}/tomcat_${prot}/conf/server.xml
        Prot=$((${prot}+1000))
        sed -i "s/9080/${Prot}/g" ${installation}/tomcat_${prot}/conf/server.xml
        chown -R ${platform}${pjname}.${platform}${pjname} ${installation} ${logs}
        su - ${platform}${pjname} -c "sh ${installation}/tomcat_${prot}/bin/startup.sh"
  • 相关阅读:
    GitHub上如何创建组织?
    windows中使用Git如何解决文件冲突?
    GitHub上如何删除代码仓库?
    并发编程模型和访问控制
    大数据征信的应用和启示:ZestFinance的基于大数据的信用评估技术
    Hadoop的Python框架指南
    Redis+Django(Session,Cookie、Cache)的用户系统
    如何使你的Ajax应用内容可让搜索引擎爬行
    Web运营手记
    全屏slider--swiper
  • 原文地址:https://www.cnblogs.com/Huang-Niu/p/10177733.html
Copyright © 2011-2022 走看看