tomcat快速部署脚本1.1

#!/bin/bash
#-*- coding: utf-8 -*-
#Date:   2019/12/19
#Author:  Mr.yang
#Version: 1.1 tomcat6
="" tomcat7="" tomcat8="" i="0" read -p "请输入项目名:" pjname name=`echo ${pjname} | sed 's/-//g'` mkdir -p /webapp/${pjname} mkdir -p /logs/${pjname} read -p "请输入平台名称:" platform && read -p "请输入用户密码:" passwd useradd ${platform}${name} echo "${passwd}" | passwd --stdin ${platform}${name} read -p "请输入端口号(关闭端口自动+1000):" prot while [ $i -le 3 ] do fin=`find /webapp/ -type d -name "*$prot"| awk -F"[/_]+" '{print $5}' | wc -l` find /webapp/ -type d -name "*$prot"| awk -F"[/_]+" '{print $5}' | wc -l if [ $fin != 0 ];then echo "端口目录存在……" && read -p "请重新输入端口号:" prot i=$((i+1)) if [ $i <= 3 ];then continue elif [ $i == 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 "无端口重复,继续进行……" break fi elif [ $fin == 0 ];then echo "无端口重复……" break fi done read -p "请输入tomcat版本(6/7/8):" tomcat cd /webapp/${pjname} if [ $tomcat == 6 ];then wget $tomcat6 elif [ $tomcat == 7 ];then wget $tomcat7 elif [ $tomcat == 8 ];then wget $tomcat8 fi echo "创建中……请稍后……" tar=`ls | awk '/jdk/{print}'` tar xf /webapp/${pjname}/$tar && rm -rf /webapp/${pjname}/$tar gz=`ls | awk 'NR==1{print $1}'` mv /webapp/${pjname}/$gz /webapp/${pjname}/tomcat_$prot sed -i "s/8080/$prot/g" /webapp/${pjname}/tomcat_$prot/conf/server.xml Prot=$(($prot+1000)) sed -i "s/9080/$Prot/g" /webapp/${pjname}/tomcat_$prot/conf/server.xml chown -R $platform$name.$platform$name /webapp/${pjname} /logs/${pjname} su - $platform$name -c "sh /webapp/${pjname}/tomcat_$prot/bin/startup.sh"

猜你喜欢

转载自www.cnblogs.com/Huang-Niu/p/12067847.html