码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本源码安装tomcat

时间:2018-11-24 19:49:47      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:java   profile   XML   ash   glob   jdk   lsof   files   https   

#!/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

标签:java   profile   XML   ash   glob   jdk   lsof   files   https   

原文地址:http://blog.51cto.com/14036860/2321488

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!