本文共 2221 字,大约阅读时间需要 7 分钟。
#!/bin/bash
##tomcat install##2018.11.23##tomcat版本8.5.35,jdk-8u191-linux-x64.tarPWD=/usr/local/srcDIR=/usr/localIP=$(ip a |grep "scope global" |awk '{print $2}'|awk -F '/' '{print $1}')yum -y install lrzsz wget unzip vim lsofecho "------------------------------安装JDK--------------------------"if [ -f $PWD/jdk-8u191-linux-x64.tar.gz ];thencd $PWDif [ -d $PWD/jdk1.8.0_191 ];thenecho "检测到JDK1.8.0_191,删除重新解压"rm -rf $PWD/jdk1.8.0_191tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWDelseecho "未检测到JDK1.8.0_191,开始解压..."tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWDfielseecho "未检测到jdk-8u191-linux-x64.tar.gz ,开始下载https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1542943486_ea7b795db30eb5d75941d7efd70be380"wget ''firpm -qa |grep javacd $PWD && mv $PWD/jdk1.8.0_191/ $DIR/javajava -versionif [ $? -ne 0 ];thenecho "增加java环境变量"echo "export JAVA_HOME=$DIR/java">>/etc/profileecho "export PATH=$PATH:/$DIR/java/bin">>/etc/profilesource /etc/profileelseecho "java变量已设置"fiecho "查看JDK版本信息"java -versionecho "-------------------------------安装tomcat---------------------"if [ -f $PWD/apache-tomcat-8.5.35.tar.gz ];thencd $PWDif [ -d $PWD/apache-tomcat-8.5.35 ];thenecho "检测到apache-tomcat-8.5.35,删除重新解压... "rm -rf $PWD/apache-tomcat-8.5.35tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWDelseecho "未检测到apache-tomcat-8.5.35目录,开始解压..."tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWDfielseecho "未检测到apache-tomcat-8.5.35.tar.gz软件包,开始下载http://124.205.69.163/files/5015000007330888/mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz"cd $PWDwget ''fiif [ -d $DIR/tomcat ];thenecho "检测到tomcat目录,删除复制"rm -rf $DIR/tomcatmv $PWD/apache-tomcat-8.5.35 $DIR/tomcatelseecho "未检测到tomcat目录,开始复制..."mv $PWD/apache-tomcat-8.5.35 $DIR/tomcatfiecho "--------------------导入tomcat的配置文件-----------------"cat $DIR/src/server.xml>$DIR/tomcat/conf/server.xmlcat $DIR/src/catalina.sh>$DIR/tomcat/bin/catalina.shecho "---------------------启动tomcat---------------------"/usr/local/tomcat/bin/startup.shecho "查看启动情况"lsof -i:8080netstat -utpln |grep 80转载于:https://blog.51cto.com/14036860/2321488