shell脚本源码安装tomcat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本源码安装tomcat相关的知识,希望对你有一定的参考价值。
#!/bin/bash
##tomcat install
##2018.11.23
##tomcat版本8.5.35,jdk-8u191-linux-x64.tar
PWD=/usr/local/src
DIR=/usr/local
IP=$(ip a |grep "scope global" |awk ‘{print $2}‘|awk -F ‘/‘ ‘{print $1}‘)
yum -y install lrzsz wget unzip vim lsof
echo "------------------------------安装JDK--------------------------"
if [ -f $PWD/jdk-8u191-linux-x64.tar.gz ];then
cd $PWD
if [ -d $PWD/jdk1.8.0_191 ];then
echo "检测到JDK1.8.0_191,删除重新解压"
rm -rf $PWD/jdk1.8.0_191
tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWD
else
echo "未检测到JDK1.8.0_191,开始解压..."
tar xf $PWD/jdk-8u191-linux-x64.tar.gz -C $PWD
fi
else
echo "未检测到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 ‘https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1542943486_ea7b795db30eb5d75941d7efd70be380‘
fi
rpm -qa |grep java
cd $PWD && mv $PWD/jdk1.8.0_191/ $DIR/java
java -version
if [ $? -ne 0 ];then
echo "增加java环境变量"
echo "export JAVA_HOME=$DIR/java">>/etc/profile
echo "export PATH=$PATH:/$DIR/java/bin">>/etc/profile
source /etc/profile
else
echo "java变量已设置"
fi
echo "查看JDK版本信息"
java -version
echo "-------------------------------安装tomcat---------------------"
if [ -f $PWD/apache-tomcat-8.5.35.tar.gz ];then
cd $PWD
if [ -d $PWD/apache-tomcat-8.5.35 ];then
echo "检测到apache-tomcat-8.5.35,删除重新解压... "
rm -rf $PWD/apache-tomcat-8.5.35
tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWD
else
echo "未检测到apache-tomcat-8.5.35目录,开始解压..."
tar zxvf $PWD/apache-tomcat-8.5.35.tar.gz -C $PWD
fi
else
echo "未检测到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 $PWD
wget ‘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‘
fi
if [ -d $DIR/tomcat ];then
echo "检测到tomcat目录,删除复制"
rm -rf $DIR/tomcat
mv $PWD/apache-tomcat-8.5.35 $DIR/tomcat
else
echo "未检测到tomcat目录,开始复制..."
mv $PWD/apache-tomcat-8.5.35 $DIR/tomcat
fi
echo "--------------------导入tomcat的配置文件-----------------"
cat $DIR/src/server.xml>$DIR/tomcat/conf/server.xml
cat $DIR/src/catalina.sh>$DIR/tomcat/bin/catalina.sh
echo "---------------------启动tomcat---------------------"
/usr/local/tomcat/bin/startup.sh
echo "查看启动情况"
lsof -i:8080
netstat -utpln |grep 80
以上是关于shell脚本源码安装tomcat的主要内容,如果未能解决你的问题,请参考以下文章